6

I'm somewhat new to web app development, and ran through the Yeoman tutorial, which uses yo, grunt, bower, and angular.

I had used homebrew to install node and npm, but kept getting errors with npm due to some permissions and whatnot. I uninstalled node using brew, and instead used nvm to install node and npm, which no longer gives me errors.

BUT, nvm is somewhat annoying. I understand it's a node version manager, and I'm fine with having to nvm use 0.10 every time I open a shell. But now, whenever I want to grunt serve my web app from a new shell, I need to install grunt-cli:

nvm use 0.10
npm install -g grunt-cli
# ...
grunt serve

Is grunt-cli not installing globally? Or is it meaningless, because npm doesn't 'stick around' between different shells?

Basically, I'm fine with just using one version of node right now. How do I set up nvm, npm, and grunt so I don't have to re-install grunt every time I open a new shell?

ryantuck
  • 6,146
  • 10
  • 57
  • 71
  • about two weeks later, and the problem seemed to have resolved itself. I can now `grunt serve` without calling nvm or npm at all. – ryantuck Oct 02 '14 at 21:02
  • I'm experiencing the same issue as you did: I need to run `nvm use` and `npm install` every time to be able to launch grunt.. Let me know if you ever find out how the problem got solved. – fkoessler Nov 30 '14 at 08:40
  • 3
    i believe `nvm alias default v0.10.33` (or whatever version you want to use) will resolve most issues. this means you won't have to type `nvm use` every time you open a new shell. See here: http://stackoverflow.com/questions/24585261/nvm-keeps-forgetting-node-in-new-terminal-session – ryantuck Nov 30 '14 at 16:52
  • Awesome, that fixed it. You should answer your own question. – fkoessler Dec 01 '14 at 07:23
  • This issue is really annoying. For me the fix was to use `nvm use ` several times, then `npm install grunt`. Error appeared then I finally was able to install all packages including grunt that was in package.json. Then at last I could use grunt .... – Seyhak Ly Dec 02 '20 at 09:35
  • Workaround: Run the locally installed version of grunt directly: `./node_modules/.bin/grunt` instead of the global `grunt` command. – pixelbrackets Dec 18 '20 at 21:43

2 Answers2

0

Go to your command prompt and try "nvm alias default ". If you want to use version "0.12.7" then your command will be "nvm alias default 0.12.7" and to cross check if the version is used globally open a new command prompt and use command "node -v".

-1

Instead of using nvm use everytime you could leave an .nvmrc file

As from the docs:

echo "0.12" >> .nvmrc 

Now the next time you enter that directory nvm will read that file and load that specific version.

You can check if its working with

nvm use
Lomefin
  • 1,173
  • 12
  • 43