node icon indicating copy to clipboard operation
node copied to clipboard

Error: Cannot find module 'internal/fs' when npm install on mac

Open shufanshijie opened this issue 10 years ago β€’ 95 comments

5 verbose stack Error: Cannot find module 'internal/fs'
5 verbose stack     at Function.Module._resolveFilename (module.js:472:15)
5 verbose stack     at Function.Module._load (module.js:420:25)
5 verbose stack     at Module.require (module.js:500:17)
5 verbose stack     at require (internal/module.js:20:19)
5 verbose stack     at evalmachine.<anonymous>:17:20
5 verbose stack     at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/cmd-shim/node_modules/graceful-fs/fs.js:11:1)
5 verbose stack     at Module._compile (module.js:573:32)
5 verbose stack     at Object.Module._extensions..js (module.js:582:10)
5 verbose stack     at Module.load (module.js:490:32)
5 verbose stack     at tryModuleLoad (module.js:449:12)
6 verbose cwd /Users/huweiqing
7 error Darwin 14.5.0
8 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "iconv-lite"
9 error node v7.0.0
10 error npm  v3.10.8
11 error code MODULE_NOT_FOUND
12 error Cannot find module 'internal/fs'

shufanshijie avatar Oct 31 '16 13:10 shufanshijie

Hm, can you read over the discussion in https://github.com/nodejs/node/issues/9355.

cjihrig avatar Oct 31 '16 13:10 cjihrig

I'm getting a https://github.com/nodejs/node/issues/3606 vibe from these. Smells like an installer problem.

Fishrock123 avatar Oct 31 '16 13:10 Fishrock123

@shufanshijie

What is the output of node -v and npm -v? How did you install Node.js?

Fishrock123 avatar Oct 31 '16 13:10 Fishrock123

If you run rm -rf /usr/local/lib/node_modules/npm and then re-install Node.js does it work?

Fishrock123 avatar Oct 31 '16 13:10 Fishrock123

Unable to reproduce the problem.

➜  ~ node -v
v7.0.0
➜  ~ npm -v
3.10.8
➜  ~ uname -v
Darwin Kernel Version 15.6.0: Thu Sep  1 15:01:16 PDT 2016; root:xnu-3248.60.11~2/RELEASE_X86_64
➜  ~ npm i iconv-lite
/Users/thefourtheye
└── [email protected]

Could be because of the stale npm installation, but not sure how that could have happened though. Please try what @Fishrock123 suggested above.

thefourtheye avatar Oct 31 '16 16:10 thefourtheye

Same problem for me on a MacOsX Sierra:

$ uname -v
Darwin Kernel Version 16.1.0: Thu Oct 13 21:26:57 PDT 2016; root:xnu-3789.21.3~60/RELEASE_X86_64
$ node -v
v7.0.0
$ npm -v
3.10.8

I tried to uninstall / reinstall, but it didn't fix the problem

giulio-sefaira avatar Nov 01 '16 10:11 giulio-sefaira

@shufanshijie @giulio-sefaira How did you install node? With brew or nvm? Or directly from https://nodejs.org/en/download/ ?

gibfahn avatar Nov 01 '16 11:11 gibfahn

hi @gibfahn . I used brew. I uninstalled node, wiped entirely the node_modules library (rm -rf /usr/local/lib/node_modules) and reinstalled by brew

giulio-sefaira avatar Nov 01 '16 11:11 giulio-sefaira

I tried to reinstall node with brew and delete entire /usr/local/lib/node_modules, the error still happens.

OnceMore2020 avatar Nov 01 '16 11:11 OnceMore2020

@giulio-sefaira @OnceMore2020 could you please run which npm?

Fishrock123 avatar Nov 01 '16 13:11 Fishrock123

@Fishrock123

$ which npm
npm is /usr/local/bin/npm
npm is /usr/local/bin/npm
npm is /usr/local/bin/npm

giulio-sefaira avatar Nov 01 '16 14:11 giulio-sefaira

$ /usr/local/bin/npm -v 3.10.8

giulio-sefaira avatar Nov 01 '16 14:11 giulio-sefaira

get this error in Ubuntu 16.04 node -v = v7.0.0 npm -v = 3.10.8

Leolik avatar Nov 01 '16 17:11 Leolik

@Leolik How did you install node?

gibfahn avatar Nov 01 '16 17:11 gibfahn

@gibfahn sudo n latest but after reading #9355 and removing /usr/local/lib/node_modules/ - error not reproduced

Leolik avatar Nov 01 '16 17:11 Leolik

Also after removing /usr/local/lib/node_modules/ and the local project node_modules - error gone.

vodrazka avatar Nov 02 '16 08:11 vodrazka

I solved this issue thanks to the answer of @Leolik and @fane89

gabrielperales avatar Nov 02 '16 09:11 gabrielperales

I ran into this problem too, but was able to resolve it by rolling back to an older version of node/npm and forcing a "flush" of the npm module:

$ sudo n 6.
$ sudo npm install -g [email protected]
$ sudo npm install -g npm@next
$ sudo n 7.

spelunk avatar Nov 02 '16 18:11 spelunk

Using Mac OS Sierra and installed Node + npm via Homebrew.

This is still not functional for me. I've gone through the thread and continue to have:

Cannot find module 'internal/fs'

verbose cli 'install' ] 2 info using [email protected] 3 info using [email protected] 4 verbose stack Error: Cannot find module 'internal/fs'

I've removed /usr/local/lib/node_modules/ and reinstalled node etc etc. to no avial @giulio-sefaira are you in the clear yet?

Swelly avatar Nov 03 '16 19:11 Swelly

Since I assume this kind of thing is also popping up on the npm issue tracker… @nodejs/npm @KenanY do you know what’s up with this?

addaleax avatar Nov 03 '16 19:11 addaleax