Skip to content
This repository has been archived by the owner. It is now read-only.

getting "Cannot find module 'internal/fs'" in Node.js v7.0.0 #14232

Closed
Gcaufy opened this issue Oct 11, 2016 · 80 comments
Closed

getting "Cannot find module 'internal/fs'" in Node.js v7.0.0 #14232

Gcaufy opened this issue Oct 11, 2016 · 80 comments

Comments

@Gcaufy
Copy link

@Gcaufy Gcaufy commented Oct 11, 2016

I'm opening this issue because:

  • npm is crashing.

What's going wrong?

When I use node v6.7.0, I do npm install, it works well.
After I upgrade to v7.0.0-nightly, I get an error:

Cannot find module 'internal/fs'

Then I downgrade to v6.7.0, it works well again.

Errors

npm ERR! Windows_NT 6.1.7601
npm ERR! argv "D:\\installed\\nodejs\\node.exe" "D:\\installed\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "express-generator"
npm ERR! node v7.0.0-nightly201609202b5acda7a2
npm ERR! npm  v3.10.3
npm ERR! code MODULE_NOT_FOUND

npm ERR! Cannot find module 'internal/fs'
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     E:\code\mine\js\success_with_social\npm-debug.log

Detail

$ node -v
v7.0.0-nightly201609202b5acda7a2
$ npm -v
3.10.3
$ npm install -g something
##### Geting error here

##### Then I downgrade to v6.7.0
$ node -v
v6.7.0
$ npm -v
3.10.3
$ npm install -g something
(node:72796) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.
C:\Users\changong\AppData\Roaming\npm
`-- something@0.0.1

Other

I also checked this issue #12880
But I tried to uninstall and install many times, it does not work for me.

I download Node.js from these two links:
V6.7.0
v7.0.0

@othiym23
Copy link
Contributor

@othiym23 othiym23 commented Oct 11, 2016

You're going to need to upgrade to npm@3.10.9 (currently npm@next – npm -g install npm@next if you have it installed globally, npm-windows-upgrade to make it easier on Windows), because there's a backwards-incompatible change made to Node's internals that require a newer version of graceful-fs, a utility package heavily used by the npm CLI. Thanks for your time!

@othiym23 othiym23 closed this Oct 11, 2016
@othiym23
Copy link
Contributor

@othiym23 othiym23 commented Oct 11, 2016

Also, you should be able to use the version of npm packaged with Node 7.0.0, but you may need to manually delete any copies of npm that don't get uninstalled by Node's uninstall script.

@Gcaufy
Copy link
Author

@Gcaufy Gcaufy commented Oct 13, 2016

cool, works for me. after I upgrade npm to 3.10.9. it was fixed

@piotr-cz
Copy link

@piotr-cz piotr-cz commented Oct 26, 2016

If this happens when running gulp, you have to downgrade nodejs to v6, see gulpjs/gulp#1843

@tim-mc
Copy link

@tim-mc tim-mc commented Oct 26, 2016

This error is also happening for me with node 7, npm versions 3.10.9 & 4.0.1. Should I open a separate issue?

@jackiehluo
Copy link

@jackiehluo jackiehluo commented Oct 26, 2016

Same as @tim-mc!

@hult
Copy link

@hult hult commented Oct 27, 2016

Had the same issue as @tim-mc @jackiehluo, tried different versions of npm (including the one packaged with node), but it didn't help. Removing my node_modules and reinstalling all packages worked splendidly, though.

@piotr-cz
Copy link

@piotr-cz piotr-cz commented Oct 27, 2016

Check error stack trace, there is a change that there is a dependency vinyl-fs: 0.3.0 which is causing this

@heziqiang
Copy link

@heziqiang heziqiang commented Oct 27, 2016

@othiym23 it works by upgrading npm to npm@3.10.9, thanks!

@ymc-sise
Copy link

@ymc-sise ymc-sise commented Oct 27, 2016

Same as @tim-mc!

@tim-mc
Copy link

@tim-mc tim-mc commented Oct 27, 2016

FWIW, I've tried removing node_modules and rebuilding. It does not solve the issue. I'm also using Sierra, not Windows.

@joelself
Copy link

@joelself joelself commented Oct 27, 2016

I can't upgrade npm because I get the same Cannot find module 'internal/fs' error when I try to upgrade:

username@machine:~/$  npm install npm@3.10.9
npm ERR! Linux 3.13.0-91-generic
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "npm@3.10.9"
npm ERR! node v7.0.0
npm ERR! npm  v3.10.8
npm ERR! code MODULE_NOT_FOUND

npm ERR! Cannot find module 'internal/fs'
npm ERR! 
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>
@guyellis
Copy link

@guyellis guyellis commented Oct 27, 2016

@joelself I found that to get around that problem I had to:

  1. Switch Node from 7.0.0 back to 6.x
  2. Then run npm -g install npm@next (or whatever version you want)
  3. Then switch back to Node 7.0.0

Edit: As per @gempain comment below you can use n or nvm to switch between Node versions.

@vuongtran
Copy link

@vuongtran vuongtran commented Oct 28, 2016

@guyellis It work fine for me. Thanks!

@juanmarinballastlane
Copy link

@juanmarinballastlane juanmarinballastlane commented Oct 28, 2016

Works for me removing the node_modules folder and install again

@gempain
Copy link

@gempain gempain commented Nov 1, 2016

@guyellis completing your comment:
Use command n to switch between NodeJS versions.

@guyellis
Copy link

@guyellis guyellis commented Nov 1, 2016

@gempain thanks. I should have mentioned that n and nvm are node version managers. Not sure if there are others?

@gempain
Copy link

@gempain gempain commented Nov 6, 2016

@guyellis not sure either. But I think your comment is perfect as is. I guess I should've known how to switch between node versions. But the Google search took me a minute, so not too bad :)

kelly-vernon-volusion added a commit to kelly-vernon-volusion/runscope-api-wrapper that referenced this issue Nov 18, 2016
@one-aalam
Copy link

@one-aalam one-aalam commented Nov 24, 2016

@guyellis Thanks! worked like a charm

@thedillonb
Copy link

@thedillonb thedillonb commented Nov 30, 2016

This doesn't appear to be fixed in 3.10.9 as suggested above. Pulling the latest NodeJS current release (7.2.0) which bundles NPM 3.10.9 still results in failure:

[dbuchanan@localhost server (normal-work)]$ npm --version
3.10.9
[dbuchanan@localhost server (normal-work)]$ npm test
module.js:472
    throw err;
    ^

Error: Cannot find module 'internal/fs'
    at Function.Module._resolveFilename (module.js:470:15)
    at Function.Module._load (module.js:418:25)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at evalmachine.<anonymous>:17:20
    at Object.<anonymous> (/code/i95/web/server/node_modules/vinyl-fs/node_modules/graceful-fs/fs.js:11:1)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
[dbuchanan@localhost server (normal-work)]$
@xpolb01
Copy link

@xpolb01 xpolb01 commented Nov 30, 2016

I had the same issue. What I did was the following:

  1. using "n" I switched back to the node version 6.9.1 n 6.9.1
  2. installed lates npm sudo npm -g install npm@next
  3. switch back to node 7.2.0 n 7.2.0
  4. everything works
@bountyx
Copy link

@bountyx bountyx commented Dec 1, 2016

@guyellis Same issue, your instructions also worked for me. Can anyone shed light onto WHY that fixes the issue?

@lsommaruga
Copy link

@lsommaruga lsommaruga commented Dec 2, 2016

@xpolb01 Thnks also work for me OS X Yosemite 10.10.5 (got the error while installing nodemon module npm install -g nodemon )

@tim-mc
Copy link

@tim-mc tim-mc commented Dec 2, 2016

Resolved my issue - Bower was the culprit. We had some legacy code in our codebase that still depended on it.

@mitchallen
Copy link

@mitchallen mitchallen commented Feb 14, 2017

Fortunately GitHub provides a mute-this-thread option ...

@vitalygoji
Copy link

@vitalygoji vitalygoji commented Feb 14, 2017

@fabrikate
Copy link

@fabrikate fabrikate commented Feb 16, 2017

I am getting this same issue.
Node: v7.4.0
NPM: 4.0.5

Anytime I try and npm install I get the following error:

npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v7.4.0
npm ERR! npm  v4.0.5
npm ERR! code MODULE_NOT_FOUND

npm ERR! Cannot find module 'internal/fs'
npm ERR! 
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/name/frontend/npm-debug.log

To get rid of this I uninstall npm and reinstall. Any clarity as to what is causing this issue?

@vitalygoji
Copy link

@vitalygoji vitalygoji commented Feb 16, 2017

@agalazis
Copy link

@agalazis agalazis commented Feb 19, 2017

for me even downloading didn't work for a specific package even when trying to clean install all global modules. Not sure if it's actually an npm issue anymore... xD

@fabrikate
Copy link

@fabrikate fabrikate commented Feb 19, 2017

For me I get this issue when I switch my versions of node. ( Work is 4.2, Projects I use 7.5 ). Two work arounds are to use homebrew to uninstall then install npm OR create a VM.

@BrianO
Copy link

@BrianO BrianO commented Feb 19, 2017

I have followed the tip above by "jessaustin" about removing Node 7.. version and going back to 6.9 version. I notice the Node website says "Latest LTS Version: v6.9.5 (includes npm 3.10.10)", but when I do "npm --version", my machine now says 2.3.0.

Should i try to update NPM to a higher version now? I do see my Dependencies errors are gone in Visual Studio 2015 Core project, but this is after so many changes, I may not be in the clear and just getting lucky that the package update succeeded somewhere along the way..

Thanks

@danhouldsworth
Copy link

@danhouldsworth danhouldsworth commented Feb 21, 2017

I've just recompiled node from source (now : node v7.5 / npm v4.1.2) and still broken. Frustratingly, I followed the earlier advice to delete node_modules/ and so now I'm stuck!

npm ERR! Linux 4.4.44-39.55.amzn1.x86_64
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "--production"
npm ERR! node v7.5.0
npm ERR! npm  v4.1.2
npm ERR! code MODULE_NOT_FOUND

npm ERR! Cannot find module 'internal/fs'
npm ERR! 
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>
@vitalygoji
Copy link

@vitalygoji vitalygoji commented Feb 21, 2017

@agalazis
Copy link

@agalazis agalazis commented Feb 21, 2017

LOL. Don't do open source, worst case scenario you will get sued. Just kidding, I am sure they are covered by their license. @vitalygoji What did you do about it? did you do a pull request and they didn't accept it?

@vitalygoji
Copy link

@vitalygoji vitalygoji commented Feb 21, 2017

@jcastrov
Copy link

@jcastrov jcastrov commented Feb 27, 2017

$ node -v 
7.5.0

$ npm -v 
4.2.0

Still with this issue

@doapp-ryanp
Copy link

@doapp-ryanp doapp-ryanp commented Mar 2, 2017

I use the n tool to manage switching between node (and the bundled npm) versions.

To fix this error, I simply removed npm from the global space (macOS): sudo rm -rf /usr/local/lib/node_modules/npm

I then re-ran sudo n latest. This will re-install npm. When switching back to previous version of node just run sudo n 4.3.2.

To summarise:

> sudo rm -rf /usr/local/lib/node_modules/npm
> sudo n latest
> node --version
v7.7.1
> npm --version
4.1.2
> sudo n 4.3.2
> npm --version
2.14.12

Here are some other suggestions that did not work for me: http://stackoverflow.com/questions/40308623/cannot-find-module-internal-fs-afer-upgrading-to-node-7

@rsibanez89
Copy link

@rsibanez89 rsibanez89 commented Mar 4, 2017

node -v
v7.7.1
npm -v
4.1.2

Works fine for me.
For changing npm version

npm install -g npm@4.1.2

@JohnnyWalkerDesign
Copy link

@JohnnyWalkerDesign JohnnyWalkerDesign commented Mar 27, 2017

@doapp-ryanp Thanks! Your solution was the one that worked for me.

Frustrating bug!

@codinronan
Copy link

@codinronan codinronan commented May 15, 2017

In my case, the problem was bower - I was on 1.7.3, Node 7.7.4, npm 4.1. Upgrading Bower to 1.8.0 solved the issue for me.

@agalazis
Copy link

@agalazis agalazis commented May 16, 2017

since the issue is upgrading one solution is docker... do clean builds/runs in docker xD

@samvloeberghs
Copy link

@samvloeberghs samvloeberghs commented May 19, 2017

going back to v6.9.5 fixed it for me. Easily achieved with nvm

@vanessarusu
Copy link

@vanessarusu vanessarusu commented May 20, 2017

deleting the node_modules and running npm install worked for me!

@siddo420
Copy link

@siddo420 siddo420 commented Jun 21, 2017

@vanessarusu did you delete global node_modules folder?

rm -rf /usr/local/lib/node_modules/

@siddo420
Copy link

@siddo420 siddo420 commented Jun 21, 2017

I renamed the folder and tried but didn't work

@shubham-chaudhari
Copy link

@shubham-chaudhari shubham-chaudhari commented Jul 11, 2017

npm -g install npm@next resolved for me....

@pyotrritchie
Copy link

@pyotrritchie pyotrritchie commented Sep 4, 2017

$ npm install
npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module 'internal/fs'

npm -v 5.3.0
node -v v8.4.0

I had this issue on npm 4.2.0 and node 7.8.0 so updated to the above and still having the same issue.

@guntram
Copy link

@guntram guntram commented Sep 11, 2017

On Windows_NT 6.1.7601, removing the ...\AppData\Roaming\npm\node_modules worked for me.
After that, I could npm install inside my project root folder.
I rolled back Node and npm to (node: 8.1.4 / npm: 5.0.3), hoping that this "you are not admin/root" stuff doesn't come back ;)

EDIT: I did not get the error again with the mentioned versions.

@Jero786
Copy link

@Jero786 Jero786 commented Sep 16, 2017

➜  npm -v
3.10.10
➜  node -v
v6.9.5

Works fine for me too!

@alexey-sh
Copy link

@alexey-sh alexey-sh commented Jan 11, 2018

nvm install v6.9.5 works. (+reinstall node modules)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet