New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

npm ERR! Cannot find module 'internal/util/types' (tested with n lts and n latest) #476

Closed
sugizo opened this Issue Nov 20, 2017 · 6 comments

Comments

Projects
None yet
5 participants
@sugizo

sugizo commented Nov 20, 2017

$ uname
Darwin
$ sudo npm install -g n
$ n --version
2.1.7
$ which n
/usr/local/bin/n
$ sudo -i

node -v

v6.11.2

npm -v

3.10.10

npm cache clean -f

npm WARN using --force I sure hope you know what you are doing.

n lts

exit

$ sudo -i

n

node/8.9.1

node -v

v8.9.1

npm -v

5.5.1

npm cache clean -f

npm WARN using --force I sure hope you know what you are doing.
npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module 'internal/util/types'

npm ERR! A complete log of this run can be found in:
npm ERR! /var/root/.npm/_logs/2017-11-20T02_17_51_442Z-debug.log

exit

$ sudo -i

node -v

v6.11.2

npm -v

3.10.10

npm cache clean -f

npm WARN using --force I sure hope you know what you are doing.

n stable

exit

$ sudo -i

n

node/9.2.0

node -v

v9.2.0

npm -v

5.5.1

npm cache clean -f

npm WARN using --force I sure hope you know what you are doing.
npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module 'internal/util/types'

npm ERR! A complete log of this run can be found in:
npm ERR! /var/root/.npm/_logs/2017-11-20T02_16_00_192Z-debug.log

exit

@JohnRGee

This comment has been minimized.

Contributor

JohnRGee commented Nov 22, 2017

I was not able to reproduce starting from a clean install of node 6.11.2, but was able to reproduce by starting from a clean install of node 4.0.0 (and then using n to upgrade to 6.11.2, 8.9.0, 9.2.0).

@mohsinhijazee

This comment has been minimized.

mohsinhijazee commented Nov 23, 2017

Try following:

$ n 6.12.0 # Go back to a stable release
$ npm install -g npm@latest # Update npm to latest
$ n lts # Get 8.9.1
$ npm install webpack #Should work now.
And things from here onwards should work.

In general, usually, it is about moving back and forth between npm versions.

@JohnRGee

This comment has been minimized.

Contributor

JohnRGee commented Nov 25, 2017

The root cause is that n is overwriting the previous install. Sometimes the left over files from previous installs cause problems with npm.

Two possible work-arounds to get npm working again when this happens are:

  1. manually remove node and npm, then rerun n with the desired version. e.g. with default install locations and write permission:
rm /usr/local/bin/node
rm -rf /usr/local/lib/node_modules/npm
n lts
  1. Reinstall node using nodes.org installer (which tries harder to do a clean install of npm).
@sugizo

This comment has been minimized.

sugizo commented Dec 7, 2017

yes, thanks, i took the 2nd option reinstall node (lts) and it works fine now

@Rahul-Bisht

This comment has been minimized.

Rahul-Bisht commented Jan 23, 2018

so, i installed node -v 8.9.4 via nvm & noticed that it was not installing npm in node_modules folder. so, while it was downloading npm -v 5.6.0, i made a copy of zip and manually put it inside node_modules.
it worked for me on win10 machine.

it will download new npm at C:\Users[userName]\AppData\Roaming\nvm\temp\ , you should copy it to
C:\Users[userName]\AppData\Roaming\nvm\v8.9.4\node_modules\npm

p.s:- you should be quick to copy npm's zip as it will remove it immediately.

@sugizo sugizo closed this Feb 2, 2018

@jroporto

This comment has been minimized.

jroporto commented Mar 27, 2018

In Windows 7, I have solved the problem deleting the folders:

C:\Users\youruser\AppData\Roaming\npm
C:\Users\youruser\AppData\Roaming\npm-cache

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment