即使我已经卸载了Homebrew的节点版本,npm仍然会将软件包安装到'/ usr / local / Cellar / node / ...'

时间:2022-09-19 07:58:49

It's been a long night. Originally I had node installed from the package on https://nodejs.org/. However, for some reason (I can't remember why now!), I decided to try uninstalling this and then installing node through Homebrew.

这是一个漫长的夜晚。最初我在https://nodejs.org/上的软件包中安装了节点。但是,出于某种原因(我现在不记得为什么!),我决定尝试卸载它,然后通过Homebrew安装节点。

Everything seemed to go fine. I then ran the following:

一切似乎都没事。然后我运行了以下内容:

$ npm install grunt -g
$ npm install grunt-cli -g

But then when I tried running any of my Grunt tasks I get the following:

但是当我尝试运行任何Grunt任务时,我得到以下内容:

$ cd /some/project/that/used/grunt
$ grunt
-bash: grunt: command not found

I tried uninstalling the Homebrew version of node:

我尝试卸载Homebrew版本的节点:

$ brew uninstall node

I then installed the nodejs.org package again. However when I try to install an npm package it ends up back in the /usr/local/Cellar/node/... directory:

然后我再次安装了nodejs.org包。但是当我尝试安装一个npm包时,它最终会回到/ usr / local / Cellar / node / ...目录中:

$ sudo npm install grunt -g
Password:
grunt@0.4.5 /usr/local/Cellar/node/0.12.2_1/libexec/npm/lib/node_modules/grunt
├── which@1.0.9
...    

I also found https://github.com/Homebrew/homebrew/issues/22408 and tried the symlink:

我还找到了https://github.com/Homebrew/homebrew/issues/22408并尝试了符号链接:

$ ln -sf /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm

No luck. How can I get npm to stop installing packages in /usr/local/Cellar/... and get Grunt running again? Thank you!

没有运气。如何让npm停止在/ usr / local / Cellar / ...中安装软件包并让Grunt再次运行?谢谢!

1 个解决方案

#1


5  

This seemed to work. I found the following in /usr/local/lib/node_modules/npm/npmrc:

这似乎有效。我在/ usr / local / lib / node_modules / npm / npmrc中找到了以下内容:

prefix=/usr/local/Cellar/node/0.12.2_1/libexec/npm

I removed this line and re-installed the grunt and grunt-cli packages. It works now.

我删除了这一行并重新安装了grunt和grunt-cli包。它现在有效。

#1


5  

This seemed to work. I found the following in /usr/local/lib/node_modules/npm/npmrc:

这似乎有效。我在/ usr / local / lib / node_modules / npm / npmrc中找到了以下内容:

prefix=/usr/local/Cellar/node/0.12.2_1/libexec/npm

I removed this line and re-installed the grunt and grunt-cli packages. It works now.

我删除了这一行并重新安装了grunt和grunt-cli包。它现在有效。