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

Created on 20 Nov 2017  路  7Comments  路  Source: tj/n

$ 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

Most helpful comment

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.

All 7 comments

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:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

shadowspawn picture shadowspawn  路  8Comments

hzhu picture hzhu  路  9Comments

GeoffreyBooth picture GeoffreyBooth  路  8Comments

Olgagr picture Olgagr  路  4Comments

benpptung picture benpptung  路  9Comments