$ uname
Darwin
$ sudo npm install -g n
$ n --version
2.1.7
$ which n
/usr/local/bin/n
$ sudo -i
v6.11.2
3.10.10
npm WARN using --force I sure hope you know what you are doing.
$ sudo -i
node/8.9.1
v8.9.1
5.5.1
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
$ sudo -i
v6.11.2
3.10.10
npm WARN using --force I sure hope you know what you are doing.
$ sudo -i
node/9.2.0
v9.2.0
5.5.1
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
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).
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.
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
2) Reinstall node using nodes.org installer (which tries harder to do a clean install of npm).
yes, thanks, i took the 2nd option reinstall node (lts) and it works fine now
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\Roamingnvm\temp\ , you should copy it to
C:\Users[userName]\AppData\Roamingnvm\v8.9.4node_modulesnpm
p.s:- you should be quick to copy npm's zip as it will remove it immediately.
In Windows 7, I have solved the problem deleting the folders:
C:\Users\youruser\AppData\Roamingnpm
C:\Users\youruser\AppData\Roamingnpm-cache
@jroporto Thanks you! It work for me! :+1:
Most helpful comment
Try following:
In general, usually, it is about moving back and forth between npm versions.