npm doesn't work, get always this error -> Err

2019-01-13 00:32发布

i tried to install grunt on a mac with Yosemite. node is already installed in the newest version. if i type "node -v" in the terminal i get the line v0.12.5. thats good. but when i want to install something with npm i get only a error...

i tried "sudo npm install -g grunt-cli", "sudo npm install npm -g" and also with "npm -v" i get always this error...

Error: Cannot find module 'are-we-there-yet'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/usr/local/Cellar/node/0.10.22/lib/node_modules/npm/node_modules/npmlog/log.js:2:16)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)

someone knows what's the problem or better a solution?

11条回答
ら.Afraid
2楼-- · 2019-01-13 00:58

You could also reinstall node from https://nodejs.org/en/download/current/

查看更多
我只想做你的唯一
3楼-- · 2019-01-13 00:59

I followed the instructions above (what eush77 said) to remove the npm folder in the node_modules folder. But there remains the broken link resulting in this error message.

/usr/local/bin/npm: No such file or directory

so remove the broken link:

rm /usr/local/bin/npm

and then make it point to the right place like this:

sudo ln -s /usr/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm

查看更多
狗以群分
4楼-- · 2019-01-13 01:00

I got it reset by using the official installer package found: https://nodejs.org/en/

Playing around with n and nvm eventually corrupted the node_modules packages for me by providing packages incompatible with current Node version.

I suspect it'd work for other environments as it couples both Node AND npm install.

查看更多
虎瘦雄心在
5楼-- · 2019-01-13 01:00

I just had the same problem while deploying the project on local server when I was invoking the yarn dev command.

After going through all the blogs, articles and stuff I got it working just by simple this 2 commands.

  1. npm list check at what version it is pointing right now. For me, when I was getting this error. It was pointing to the system.

  2. I just used the nvm use v{VERSION} e.g. nvm use v10.5.0 (for me) and it got working. All the errors went away and the project got deployed successfully while invoking the yarn dev. Try this before doing anything else. I highly recommend.

查看更多
看我几分像从前
6楼-- · 2019-01-13 01:02

What eush77 said, but if you're on Windows:

download the latest package from https://nodejs.org/download/release/npm/

unpack, and replace the "npm" directory in the nodejs node-modules directory (by default C:\Program Files\nodejs\node_modules)

查看更多
虎瘦雄心在
7楼-- · 2019-01-13 01:07

For me this had to do with installations being corrupted and perhaps ubuntu repositories not being compatible or the most recent. The following resulted in a working npm/node install:

sudo curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash - sudo apt-get install -y nodejs

https://github.com/nodesource/distributions

查看更多
登录 后发表回答