Home » Nodejs » NVM global module folder

NVM global module folder

Posted by: admin November 29, 2017 Leave a comment

Questions:

I am using NVM and I am trying to install global NPM modules. That action requires permissions to a folder that I don’t have permissions to. With regular node.js/npm that was easy to solve with prefix configuration but NVM explicitly forbids it.

What is the right way to change the path to global modules folder in NVM?

Answers:

To see the location of the current version of node you are using:

nvm which current

You are using the system installation if .nvm is not in the path, similar to the following:

/usr/local/bin/node

To switch to a version managed by nvm:

nvm use 4

To verify you are using a version managed by nvm:

nvm which current

You should see something similar to the following:

/Users/<your-user-name>/.nvm/versions/node/v4.2.2/bin/node

You should only experience global install permission issues when you are using the system installation.

Questions:
Answers:

Inside ~/.npmrc:

prefix='some/path'

Or you can use $PREFIX shell environment:

export PREFIX="${HOME}/.local"  

Source