Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
stevenvachon opened this issue Oct 30, 2015 · 65 comments
Closed

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

stevenvachon opened this issue Oct 30, 2015 · 65 comments
Assignees
Labels
confirmed-bug Issues with confirmed bugs. install Issues and PRs related to the installers. npm Issues and PRs related to the npm client dependency or the npm registry.

Comments

@stevenvachon
Copy link

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
@evanlucas
Copy link
Contributor

Can you paste the entire stack trace?

@stevenvachon
Copy link
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>

@kenany
Copy link
Contributor

kenany commented Oct 30, 2015

ref. npm/npm#10166

@Fishrock123 Fishrock123 added confirmed-bug Issues with confirmed bugs. npm Issues and PRs related to the npm client dependency or the npm registry. labels Oct 30, 2015
@Fishrock123
Copy link
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

@Fishrock123
Copy link
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?

@nicolabortignon
Copy link

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

@Fishrock123
Copy link
Contributor

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

cc @jasnell

@Fishrock123
Copy link
Contributor

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

@Fishrock123
Copy link
Contributor

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

@jasnell
Copy link
Member

jasnell commented Oct 30, 2015

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

@Fishrock123
Copy link
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

@nicolabortignon
Copy link

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

@jasnell
Copy link
Member

jasnell commented Oct 30, 2015

Ok cool. Taking it back off the lts-watch list then.

@Fishrock123
Copy link
Contributor

@jasnell You need to not land 5652ce0 in v4.x until this fixed/confirmed.

@jasnell
Copy link
Member

jasnell commented Oct 30, 2015

Yep, as far as I can tell that one is not on the list.

@jasnell
Copy link
Member

jasnell commented Oct 30, 2015

Actually.. wait... nevermind lol... I think it was just in the batch I just did lol (double checking to make sure it's not... getting conflicting information) ... Update: Ok, nevermind, we're good. I hadn't pushed that set of changes yet, it was just in a local test branch. We're good 👍

@harsimranmaan
Copy link

Failed on OS X for me. Not able to install any packages. Works on 4.2.

@Fishrock123
Copy link
Contributor

cc @nodejs/build or @nodejs/collaborators does anyone know enough about the OS X installer to somehow make https://github.com/nodejs/node/blob/master/tools/osx-pkg.pmdoc/02npm.xml remove the previous version properly?

i.e. origin commit: 63a628d#diff-649abfdda4cfccbe318266e0c9116701L3 (Rolling back this commit will only make matters worse at this point.)

@mscdex mscdex added the macos Issues and PRs related to the macOS platform / OSX. label Nov 2, 2015
@utnas
Copy link

utnas commented Nov 3, 2015

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 15.0.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "--global"
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>

@rvagg
Copy link
Member

rvagg commented Nov 3, 2015

@Fishrock123 OSX installers are a bit of a joke, I suspect the best you can do is run a custom perl script during the installation to do a cleanup. There's no real concept of an "uninstaller" for OSX which I find baffling.

Perhaps the best way to tackle this is to look at #2571 because we're ditching the old packager anyway and this new tool might have an easier option for cleanup.

@wsmd
Copy link

wsmd commented Nov 3, 2015

I had this issue earlier today and I fixed it by removing npm (/usr/local/lib/node_modules/npm) and reinstalling node v5 again.

@edounn
Copy link

edounn commented Dec 21, 2015

rm'ing it worked for me as well, but I thought maybe I was having problems because at one time i installed it with brew, and maybe even ports too.. either way, rm all them and installing stable worked for me. thanks!

@stevenvachon
Copy link
Author

Installing newer Node updates worked without issue. Perhaps it only occurs when going from 4.x to 5.x with cached node modules.

@shaddyhm
Copy link

shaddyhm commented Jan 1, 2016

WORKS! Thanks @stevenvachon

@Fishrock123
Copy link
Contributor

Without cached node modules huh? I'll investigate more ~Monday.

@jasnell
Copy link
Member

jasnell commented Apr 2, 2016

Is this still an issue?

@MylesBorins MylesBorins mentioned this issue Apr 5, 2016
@iarna
Copy link
Member

iarna commented May 27, 2016

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

@MylesBorins
Copy link
Contributor

MylesBorins commented May 27, 2016

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

@Fishrock123
Copy link
Contributor

Is this still an issue?

... yep.

@amodkumar57
Copy link

image
image
image

@amodkumar57
Copy link

plz fix my bug as soon as possible

@MylesBorins
Copy link
Contributor

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

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

@tcosentino
Copy link

tcosentino commented Aug 5, 2016

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)

@ignacio-chiazzo
Copy link

ignacio-chiazzo commented Oct 14, 2016

Same issue when I run phonegap run ios

Output :

module.js:340

throw err;
      ^

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

phonegap/phonegap-cli#653

@GantMan
Copy link

GantMan commented Nov 1, 2016

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

@2252511944
Copy link

how to do centos

@Trott
Copy link
Member

Trott commented Jul 26, 2017

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.

@Trott Trott closed this as completed Jul 26, 2017
@mohamedmehdigara
Copy link

  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
Labels
confirmed-bug Issues with confirmed bugs. install Issues and PRs related to the installers. npm Issues and PRs related to the npm client dependency or the npm registry.
Projects
None yet
Development

No branches or pull requests