Skip to content

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

Closed

Description

@shufanshijie
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'

Activity

  1. cjihrig commented on Oct 31, 2016

    @cjihrig
    Contributor

    Hm, can you read over the discussion in #9355.

  2. Fishrock123 commented on Oct 31, 2016

    @Fishrock123
    Contributor

    I'm getting a #3606 vibe from these. Smells like an installer problem.

  3. Fishrock123 commented on Oct 31, 2016

    @Fishrock123
    Contributor

    @shufanshijie

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

  4. Fishrock123 commented on Oct 31, 2016

    @Fishrock123
    Contributor

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

  5. added
    npmIssues and PRs related to the npm client dependency or the npm registry.
    on Oct 31, 2016
  6. thefourtheye commented on Oct 31, 2016

    @thefourtheye
    Contributor

    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
    └── iconv-lite@0.4.13
    

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

  7. giulio-sefaira commented on Nov 1, 2016

    @giulio-sefaira

    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

  8. gibfahn commented on Nov 1, 2016

    @gibfahn
    Member

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

  9. giulio-sefaira commented on Nov 1, 2016

    @giulio-sefaira

    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

  10. OnceMore2020 commented on Nov 1, 2016

    @OnceMore2020

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

  11. Fishrock123 commented on Nov 1, 2016

    @Fishrock123
    Contributor

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

  12. giulio-sefaira commented on Nov 1, 2016

    @giulio-sefaira

    @Fishrock123

    $ which npm
    npm is /usr/local/bin/npm
    npm is /usr/local/bin/npm
    npm is /usr/local/bin/npm
    
  13. giulio-sefaira commented on Nov 1, 2016

    @giulio-sefaira

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

  14. Leolik commented on Nov 1, 2016

    @Leolik

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

  15. gibfahn commented on Nov 1, 2016

    @gibfahn
    Member

    @Leolik How did you install node?

  16. 71 remaining items

  17. haleyparty commented on Jun 1, 2017

    @haleyparty

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

  18. TimothyGu commented on Jun 1, 2017

    @TimothyGu
    Member

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

  19. haleyparty commented on Jun 1, 2017

    @haleyparty

    @TimothyGu Will do now!

  20. TimothyGu commented on Jun 1, 2017

    @TimothyGu
    Member

    For posterity: #13361

  21. panpepson commented on Jun 14, 2017

    @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

  22. panpepson commented on Jun 14, 2017

    @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

  23. dtruffaut commented on Jun 18, 2017

    @dtruffaut

    On Windows, I confirm that deleting the directory :

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

    solves the issue.

  24. jspblm commented on Jul 9, 2017

    @jspblm

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

  25. MichalZalecki commented on Jul 11, 2017

    @MichalZalecki

    @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.

  26. redexp commented on Jul 22, 2017

    @redexp

    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

  27. shahzadns commented on Aug 17, 2017

    @shahzadns

    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 !

  28. develucas commented on Aug 30, 2017

    @develucas

    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

  29. taylorc93 commented on Sep 18, 2017

    @taylorc93

    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.

  30. zhuziyi1989 commented on Mar 28, 2018

    @zhuziyi1989

    Reference solution: #9355

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    installIssues and PRs related to installing Node.js and its installers.npmIssues and PRs related to the npm client dependency or the npm registry.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions