Sitelet https://github.com/nodejs/node/issues/3606#top
Skip to content

Error: Cannot find module './lib' #3606

Description

@stevenvachon

Just installed node v5 and running npm in command line produces said error.

OS X 10.10.5

How to Fix

(For now)
(Edited in by @Fishrock123)

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

Activity

  1. evanlucas commented on Oct 30, 2015

    @evanlucas
    Contributor

    Can you paste the entire stack trace?

  2. stevenvachon commented on Oct 30, 2015

    @stevenvachon
    Author
    Error: Cannot find module './lib'
        at Function.Module._resolveFilename (module.js:337:15)
        at Function.Module._load (module.js:287:25)
        at Module.require (module.js:366:17)
        at require (module.js:385:17)
        at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/request/node_modules/hawk/index.js:1:80)
        at Module._compile (module.js:425:26)
        at Object.Module._extensions..js (module.js:432:10)
        at Module.load (module.js:356:32)
        at Function.Module._load (module.js:311:12)
        at Module.require (module.js:366:17)
        at require (module.js:385:17)
    npm ERR! Darwin 14.5.0
    npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm"
    npm ERR! node v5.0.0
    npm ERR! npm  v3.3.6
    npm ERR! code MODULE_NOT_FOUND
    
    npm ERR! Cannot find module './lib'
    npm ERR! 
    npm ERR! If you need help, you may report this error at:
    npm ERR!     <https://github.com/npm/npm/issues>
    
  3. kenany commented on Oct 30, 2015

    @kenany
    Contributor
  4. added
    confirmed-bugIssues and PRs for confirmed bugs.
    npmIssues and PRs related to the npm client dependency or the npm registry.
    on Oct 30, 2015
  5. Fishrock123 commented on Oct 30, 2015

    @Fishrock123
    Contributor

    I think it probably has something to do with https://github.com/nodejs/node/blob/master/tools/osx-pkg.pmdoc/02npm.xml#L9 but I don't actually understand how OS X installers work. cc @othiym23

  6. Fishrock123 commented on Oct 30, 2015

    @Fishrock123
    Contributor

    Hmmm, could 63a628d#diff-649abfdda4cfccbe318266e0c9116701L3 have been this issue? That commit was scheduled for v4.0.0 but doesn't seem to have landed until v5?

  7. nicolabortignon commented on Oct 30, 2015

    @nicolabortignon

    +1 same os version and 5.0.0.
    Can't reproduce with 4.2.1

  8. Fishrock123 commented on Oct 30, 2015

    @Fishrock123
    Contributor

    Looks like the commit is staged for v4.2.2 but has not landed in v4.x yet. 5652ce0

    cc @jasnell

  9. Fishrock123 commented on Oct 30, 2015

    @Fishrock123
    Contributor

    On second look, that seems like just an identifier though...

  10. Fishrock123 commented on Oct 30, 2015

    @Fishrock123
    Contributor

    cc @nodejs/build for anyone who knows how the OS X installer works more

  11. jasnell commented on Oct 30, 2015

    @jasnell
    Member

    @nicolabortignon ... I just want to be clear: you are not seeing this problem with v4.2.1 currently correct?

  12. Fishrock123 commented on Oct 30, 2015

    @Fishrock123
    Contributor

    @jasnell I did not have any issues with v4.2.1

    From #npm irc:

    othiym23: Fishrock123: yes, but if the installer only uninstalls the previous version before installing the new version if the manifest IDs match, that would account for the behavior everyone's seeing

  13. nicolabortignon commented on Oct 30, 2015

    @nicolabortignon

    @jasnell that is correct, 4.2.1 works like a charm.

  14. 46 remaining items

  15. self-assigned this
    on Mar 30, 2016
  16. jasnell commented on Apr 2, 2016

    @jasnell
    Member

    Is this still an issue?

  17. iarna commented on May 27, 2016

    @iarna
    Member

    @jasnell Unless the installer has been updated to remove /usr/local/lib/node_modules/npm during install this will continue to be an issue any time the shape of the npm dependency tree changes. Currently we are maintaining an npm@2 style tree in npm@3, which only changes shape very rarely, but at some point (when we drop support for 0.8) I would like to see us switch to an npm@3 style tree (that is, flat, fully deduped), but we can't w/o the installer fix as it will break anyone updating (remember 3.3.6?, ugh).

  18. MylesBorins commented on May 27, 2016

    @MylesBorins
    Contributor

    @iarna there is a PR open to change the installer (for osx at least)

    --> #5656

    It includes a commit to remove npm during install --> eff981b

    I had done some work in a branch to try and getting a script working to do this with the current installer but couldn't get it working. I plan to dig into it again, but it might not be a good use of time if the other PR is ready to land

    @rvagg what is the status of #5656?

  19. Fishrock123 commented on May 27, 2016

    @Fishrock123
    Contributor

    Is this still an issue?

    ... yep.

  20. amodkumar57 commented on Jun 9, 2016

    @amodkumar57

    image
    image
    image

  21. amodkumar57 commented on Jun 9, 2016

    @amodkumar57

    plz fix my bug as soon as possible

  22. MylesBorins commented on Jun 9, 2016

    @MylesBorins
    Contributor

    @amodkumar57 your problems look unrelated to this issue, which is about npm not working.

    Can you post over at http://github.com/nodejs/help with more information about the problem you are having

  23. tcosentino commented on Aug 5, 2016

    @tcosentino

    I don't have a node_modules folder in /usr/local/lib/ on ubuntu 14.04.. but I do have node and npm running and getting this error. Any ideas in this case? I uninstalled node and reinstalled and got the same thing.

    parallels@ubuntu:~/Documents/nikebot$ node -v
    v4.4.7
    parallels@ubuntu:~/Documents/nikebot$ npm -v
    2.15.8
    
    Error: Cannot find module './lib/'
        at Function.Module._resolveFilename (module.js:325:15)
        at Function.Module._load (module.js:276:25)
        at Module.require (module.js:353:17)
        at require (internal/module.js:12:17)
        at Object.<anonymous> (/home/parallels/Documents/nikebot/node_modules/mongoose/index.js:7:18)
        at Module._compile (module.js:409:26)
        at Object.Module._extensions..js (module.js:416:10)
        at Module.load (module.js:343:32)
        at Function.Module._load (module.js:300:12)
        at Module.require (module.js:353:17)
    
    
  24. ignacio-chiazzo commented on Oct 14, 2016

    @ignacio-chiazzo

    Same issue when I run phonegap run ios

    Output :

    module.js:340

    throw err;
          ^
    

    Error: Cannot find module './lib/run'

    phonegap/phonegap-cli#653

  25. GantMan commented on Nov 1, 2016

    @GantMan

    had this exact issue on Ubuntu bash in windows. Deleting the given folder worked perfect.

  26. 2252511944 commented on Feb 23, 2017

    @2252511944

    how to do centos

  27. Trott commented on Jul 26, 2017

    @Trott
    Member

    This issue has been inactive for sufficiently long that it seems like perhaps it should be closed. Feel free to re-open (or leave a comment requesting that it be re-opened) if you disagree. I'm just tidying up and not acting on a super-strong opinion or anything like that.

  28. mohamedmehdigara commented on Mar 21, 2023

    @mohamedmehdigara
    1. Delete node modules
    2. Delete package-lock.json
    3. Run npm install --legacy-peer-deps
    4. Run npm start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

confirmed-bugIssues and PRs for confirmed bugs.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