Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm still installing packages to '/usr/local/Cellar/node/...' even though I've uninstalled Homebrew's version of node

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.

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:

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

I tried uninstalling the Homebrew version of node:

$ 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:

$ sudo npm install grunt -g
Password:
[email protected] /usr/local/Cellar/node/0.12.2_1/libexec/npm/lib/node_modules/grunt
├── [email protected]
...    

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

$ 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!

like image 786
robertwbradford Avatar asked Apr 22 '15 04:04

robertwbradford


1 Answers

This seemed to work. I found the following in /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.

like image 184
robertwbradford Avatar answered Nov 19 '22 00:11

robertwbradford