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

Also ran into this issue when on Node 8. Set my nvm to v6.10.3 fixed the issue.

haleyparty avatar Jun 01 '17 05:06 haleyparty

@adamreisnz @haleyparty Could (one of) you create a new issue with full stack trace? Thanks!

TimothyGu avatar Jun 01 '17 05:06 TimothyGu

@TimothyGu Will do now!

haleyparty avatar Jun 01 '17 05:06 haleyparty

For posterity: https://github.com/nodejs/node/issues/13361

TimothyGu avatar Jun 01 '17 08:06 TimothyGu

Hi,

ive removed all the node.js package on my OS

apt-get purge node.js

and manually remove/clear

/home/user*/(.npm,.ionic), /root/(.npm,.ionic), /usr/lib/node_modules

manual removal of the remainder helped and update your OS and new install node.js and ionic

cu

panpepson avatar Jun 14 '17 18:06 panpepson

Hi,

ive removed all the node.js package on my OS

apt-get purge node.js

and manually remove/clear

/home/user*/(.npm,.ionic), /root/(.npm,.ionic), /usr/lib/node_modules

manual removal of the remainder helped and update your OS and new install node.js and ionic

cu

panpepson avatar Jun 14 '17 18:06 panpepson

On Windows, I confirm that deleting the directory :

C:\Users<your_username>\AppData\Roaming\npm\node_modules

solves the issue.

dtruffaut avatar Jun 18 '17 01:06 dtruffaut

@Fishrock123 Solution works for me on node v8.1.3 and npm 5.0.3

jspblm avatar Jul 09 '17 18:07 jspblm

@Fishrock123 solution is generally working 💥

If it's not working for you make sure that your version of npm is actually under /usr/local/lib/node_modules/npm. Run which npm. For node installed e.g. through ansible nodejs role it can be in: ~/nodejs/bin/npm. If that's the case then you want to rm -rf ~/nodejs/lib/node_modules/npm. Reinstall and you should be fine.

MichalZalecki avatar Jul 11 '17 11:07 MichalZalecki

I get this error when I switched to older node with nvm.

Here my solution. I tried in console which bower it gives me /usr/bin/bower it was symlink to /usr/lib/node_modules/bower/bin/bower so I just removed symlink sudo rm /usr/bin/bower and removed module itself rm -rf /usr/lib/node_modules/bower and installed bower again npm i -g bower. After that was no error

redexp avatar Jul 22 '17 17:07 redexp

For me this error came after using gulp serve command on angular1-gulp project, by removing the local node_modules folder and doing npm install solved this error.

node 7.9.0 npm 4.2.0 node installed using nvm version 0.25.1 Mac OS Sierra.

Hope this will help someone. Cheers !

shahzadns avatar Aug 17 '17 11:08 shahzadns

I also experienced it lately and solved it in the following way. For me there was a conflict but at the system level and it was caused by not cleaned properly, old nodejs installation. I couldn't use latest bower package, so after reading your comments

>whereis node_modules
node_modules: /usr/lib/node_modules /usr/local/lib/node_modules

I've deleted the second directory as it was for nodejs 6.x, and all returned to normal.

Cheers

develucas avatar Aug 30 '17 17:08 develucas

I had a similar problem and it seems that reinstalling gulp and also deleting node_modules directory in my project folder fixed the problem. I use node version 8.0.0 and npm 5.0.0.

EDIT ~ I mean this is for people having problem with graceful-fs module working with gulp.

ghost avatar Sep 07 '17 10:09 ghost

I ran into this issue as well when using lerna bootstrap. Turned out I had a node_modules folder in my home directory that had a copy of NPM in it that lerna was using. No idea how that got there, but removing it did the trick.

taylorc93 avatar Sep 18 '17 14:09 taylorc93

Reference solution: https://github.com/nodejs/node/issues/9355

zhuziyi1989 avatar Mar 28 '18 02:03 zhuziyi1989