You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Cannot find module 'internal/fs' when npm install on Node 8 using mac #13361
This looks like a bad case of dependency management, as it seems like the code that's erroring out comes from graceful-fs v3, which is known to not work with recent Node.js versions. On the other hand, the latest version of npm (5.0.0, the one bundled with Node.js 8.0.0) does not depend on graceful-fs v3 in any way.
Looking at the path of the problematic file /usr/local/lib/node_modules/npm/node_modules/cmd-shim/node_modules/graceful-fs/fs.js, my guess would be that you have set npm prefix (npm config get prefix) to a global directory that is shared between different Node.js versions (like /usr/local). This is bad: global Node.js modules should always be segregated by version, to avoid dependency troubles like this, and to ensure native modules are rebuilt correctly. In fact, a recent enoughnvmshould warn about problematic npm config get prefix settings.
I have same problem, but with other packages(boom, request, tough-cookie etc.) and each time with random package. But it always throws error at Function.Module._resolveFilename (module.js:485:15).
I use:
node - v8.0.0
npm - v5.0.3 n - v2.1.7
Assuming your node_modules dir already existed when you tried npm install, deleting the node_modules dir and installing everything from scratch gets rid of odd errors like these
rm -fr node_modules/
then
npm install
there were probably some binaries that needed recompiling with node v8
Reacted by Todmy, jony89, Richard Oliver Bray, Stephanie , John Reynoso, Vishwas Shashidhar, Bryan Barrios, Kalanj Djordje and Vladislav Alexeyev
Reacted by jaysolankiMI6, Courtney Christensen, Cleber Pacheco, Gabriel, Justin Toth, Ruan Botha, Alexey Sh, Karthikeyan Subramanian, Luis Mendes, Fahras Nur Hidayat and 1 more
@lmj0011 yes, look like it fixes my problem. Thank you.
Anyway I think it is not a better solution. I as npm user should not care about removing node_modules. Better is as it was done in previous versions of npm
FWIW I encountered the same problem this morning on my Mac (Sierra, 10.12.4). Then installed nvm and used it to install the latest version node 8.1.0, npm 5.0.3. It worked.
same problem that I have.
I already completely removed node on my mac and installed it back using homebrew
Error: Cannot find module 'natives'
at Function.Module._resolveFilename (module.js:485:15)
at Function.Module._load (module.js:437:25)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at Object. (/Users/usr/IdeaProjects/test/node_modules/vinyl-fs/node_modules/graceful-fs/fs.js:1:80)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
macOS Sierra version 10.12.3
node - v8.1.0
npm - v5.0.3
I am having the same issue. I completely uninstalled node and npm and reinstalled them using homebrew.
I also tried the suggestion above - removing node_modules and re-running npm install
That gave me a bunch of "SKIPPING OPTIONAL DEPENDENCY" messages, and finally dying with:
npm ERR! path /Users/myname/Sites/mysite/node_modules/.staging/gulp-scss-lint-f7619bde/node_modules/bluebird
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename '/Users/myname/Sites/mysite/node_modules/.staging/gulp-scss-lint-f7619bde/node_modules/bluebird' -> '/Users/myname/Sites/mysite/node_modules/.staging/bluebird-4efd5b8a'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
Just for grins I wanted to see what happened when trying to run npm.
Thanks – but I don’t have admin so I can’t do sudo.
From: ianoroceo <notifications@github.com>
Reply-To: nodejs/node <reply@reply.github.com>
Date: Friday, June 16, 2017 at 10:47 AM
To: nodejs/node <node@noreply.github.com>
Cc: Julie Lewis <Julie.Lewis@cpa.texas.gov>, Mention <mention@noreply.github.com>
Subject: Re: [nodejs/node] Cannot find module 'internal/fs' when npm install on Node 8 using mac (#13361)
CAUTION: This email originated from outside of the Texas Comptroller's email system.
DO NOT click links or open attachments unless you expect them from the sender and know the content is safe.
@RioBrewster<https://github.com/riobrewster> I find these steps helpful - https://github.com/proxy/gist.github.com/TonyMtz/d75101d9bdf764c890ef
it's the same steps I followed to uninstall node and npm on my mac
and after uninstalling, I just download the node js installer at the site - https://nodejs.org/en/
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#13361 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AB3EJYDGSMf_JaoF-tZ7BWoINr-iKdwVks5sEqN1gaJpZM4Nshv2>.
/usr/local/opt/node@6/bin/node
From: Gibson Fahnestock <notifications@github.com>
Reply-To: nodejs/node <reply@reply.github.com>
Date: Saturday, June 17, 2017 at 6:31 PM
To: nodejs/node <node@noreply.github.com>
Cc: Julie Lewis <Julie.Lewis@cpa.texas.gov>, Mention <mention@noreply.github.com>
Subject: Re: [nodejs/node] Cannot find module 'internal/fs' when npm install on Node 8 using mac (#13361)
CAUTION: This email originated from outside of the Texas Comptroller's email system.
DO NOT click links or open attachments unless you expect them from the sender and know the content is safe.
@RioBrewster<https://github.com/riobrewster> what does which node print?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#13361 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AB3EJYdI0jCLYyJke8u1etSpG9AVCz3Aks5sFGG_gaJpZM4Nshv2>.
As I've pointed out in #13361 (comment), it is necessary to separate global packages installed for a specific Node.js version. Many of the issues described here are caused by assuming (intentionally or unintentionally) packages (like npm and its dependencies) installed for an older version of Node.js will work for a newer Node.js. In other words, this is not a bug in Node.js, but rather in your setup.
To fix this, delete node_modules and start over is generally the best solution. And after doing so, I recommend using a Node.js version manager that manages npm and global packages for you. nvm does this very well. On the other hand, Homebrew and most other system-wide package installers usually do not do this well.
This thread has grown very long, and unrelated issues are starting to creep in. I will close this issue now, though we will be just as happy to help you figure this out at nodejs/help or IRC.
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
isn't whereis to locate a program? if I run whereis node_modules in my terminal I get no response.
Anyway, I looked up both folders and i don't have a folder /usr/lib/node_modules.
@justijndepover whereis also searches for sources, so I think directories are also a part of sources. Please be aware that how you've installed your nodejs is important rather than existence of particular directories. Basing on your comment only is hard to imagine what your problem really is. As I see here, the genesis of this broken behavior might be different for different cases. What is your case ?
I had node installed via the MacOS installer. I followed this guide to uninstall Node. Then I reinstalled everything with Homebrew. Now everything works again.
Activity
zimbabao commentedon Jun 1, 2017
npm 5 has some issues, does it work with npm 4.2 or any 4.x version?.
TimothyGu commentedon Jun 1, 2017
This looks like a bad case of dependency management, as it seems like the code that's erroring out comes from graceful-fs v3, which is known to not work with recent Node.js versions. On the other hand, the latest version of npm (5.0.0, the one bundled with Node.js 8.0.0) does not depend on graceful-fs v3 in any way.
Looking at the path of the problematic file
/usr/local/lib/node_modules/npm/node_modules/cmd-shim/node_modules/graceful-fs/fs.js, my guess would be that you have set npm prefix (npm config get prefix) to a global directory that is shared between different Node.js versions (like/usr/local). This is bad: global Node.js modules should always be segregated by version, to avoid dependency troubles like this, and to ensure native modules are rebuilt correctly. In fact, a recent enoughnvmshould warn about problematicnpm config get prefixsettings.Can you show the output of
npm config get prefixnvm --version?
tomsoderlund commentedon Jun 3, 2017
@haleyparty I had the same problem, but solved it by reinstalling node using
brew.That gave me a problem with
npm, which I fixed with these instructions:suzannelock commentedon Jun 4, 2017
anyone able to solve this? i am having the same issue with node v5 and npm v4
boyfunky commentedon Jun 4, 2017
anyone able to solve this? having same issue with node v5 and npm v4
lvl99 commentedon Jun 7, 2017
I'm having issues and I'm using nvm to manage my node install. Seems that whenever I install whatever version (6, 7, 8) I still get the same issue.
Todmy commentedon Jun 8, 2017
I have same problem, but with other packages(boom, request, tough-cookie etc.) and each time with random package. But it always throws error
at Function.Module._resolveFilename (module.js:485:15).I use:
node - v8.0.0
npm - v5.0.3
n - v2.1.7
lmj0011 commentedon Jun 8, 2017
Assuming your
node_modulesdir already existed when you triednpm install, deleting thenode_modulesdir and installing everything from scratch gets rid of odd errors like thesethen
there were probably some binaries that needed recompiling with
node v8Todmy commentedon Jun 9, 2017
@lmj0011 yes, look like it fixes my problem. Thank you.
Anyway I think it is not a better solution. I as npm user should not care about removing
node_modules. Better is as it was done in previous versions of npmddffx commentedon Jun 9, 2017
FWIW I encountered the same problem this morning on my Mac (Sierra, 10.12.4). Then installed nvm and used it to install the latest version node 8.1.0, npm 5.0.3. It worked.
lmj0011 commentedon Jun 9, 2017
When you choose to upgrade node versions, I believe you should
ianoroceo commentedon Jun 13, 2017
same problem that I have.
I already completely removed node on my mac and installed it back using homebrew
macOS Sierra version 10.12.3
node - v8.1.0
npm - v5.0.3
RioBrewster commentedon Jun 15, 2017
I am having the same issue. I completely uninstalled node and npm and reinstalled them using homebrew.
I also tried the suggestion above - removing node_modules and re-running npm install
That gave me a bunch of "SKIPPING OPTIONAL DEPENDENCY" messages, and finally dying with:
Just for grins I wanted to see what happened when trying to run npm.
When I try running again I get the same error.
"Error: Cannot find module 'internal/fs'"
blah blah blah
Also running:
MacOS Sierra 10.12.5
node v8.1.2
npm v5.0.3
4 remaining items
RioBrewster commentedon Jun 16, 2017
gibfahn commentedon Jun 17, 2017
@RioBrewster what does
which nodeprint?RioBrewster commentedon Jun 19, 2017
nesamouzehkesh commentedon Jul 6, 2017
switching to v6.11.0 solved the problem for me. Thanks @ianoroceo
TimothyGu commentedon Jul 6, 2017
As I've pointed out in #13361 (comment), it is necessary to separate global packages installed for a specific Node.js version. Many of the issues described here are caused by assuming (intentionally or unintentionally) packages (like npm and its dependencies) installed for an older version of Node.js will work for a newer Node.js. In other words, this is not a bug in Node.js, but rather in your setup.
To fix this, delete
node_modulesand start over is generally the best solution. And after doing so, I recommend using a Node.js version manager that manages npm and global packages for you. nvm does this very well. On the other hand, Homebrew and most other system-wide package installers usually do not do this well.This thread has grown very long, and unrelated issues are starting to creep in. I will close this issue now, though we will be just as happy to help you figure this out at nodejs/help or IRC.
robertjchristian commentedon Jul 25, 2017
Could be conflicts in node_modules folder. Good idea to make sure it's clean.
Try:
rm -rf node_modules && npm installdevelucas commentedon Aug 30, 2017
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
I've deleted the second directory as it was for nodejs 6.x, and all returned to normal.
Cheers
justijndepover commentedon Sep 7, 2017
isn't whereis to locate a program? if I run
whereis node_modulesin my terminal I get no response.Anyway, I looked up both folders and i don't have a folder
/usr/lib/node_modules.So should I still delete the latter?
Running Node v7.9.0
develucas commentedon Sep 7, 2017
@justijndepover whereis also searches for sources, so I think directories are also a part of sources. Please be aware that how you've installed your nodejs is important rather than existence of particular directories. Basing on your comment only is hard to imagine what your problem really is. As I see here, the genesis of this broken behavior might be different for different cases. What is your case ?
justijndepover commentedon Sep 7, 2017
I had node installed via the MacOS installer. I followed this guide to uninstall Node. Then I reinstalled everything with Homebrew. Now everything works again.
benmirkhah commentedon Apr 23, 2018
Reverting to node v6.9.5 fixed it for me too.