Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NVM global module folder

Tags:

node.js

nvm

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?

like image 913
Juriy Avatar asked Nov 20 '15 01:11

Juriy


People also ask

Where are global node_modules stored?

Path of Global Packages in the system: Global modules are installed in the standard system in root location in system directory /usr/local/lib/node_modules project directory. Command to print the location on your system where all the global modules are installed.

Where does NVM install global packages?

"global" installs install into the node directory. nvm doesn't upgrade node in-place so each new version of node is a new version. What you can do it not install npm modules "global"ly. If you must have them everywhere (like command-line scripts) install then in $HOME or something and put $HOME/node_modules/.

Where does NVM install node modules?

Local install (default): puts stuff in ./node_modules of the current package root. Global install (with -g): puts stuff in /usr/local or wherever node is installed. Install it locally if you're going to require() it. Install it globally if you're going to run it on the command line.

How do I install npm globally?

Install Package Globally NPM installs global packages into /<User>/local/lib/node_modules folder. Apply -g in the install command to install package globally.


1 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.

like image 107
Michael Allan Jackson Avatar answered Oct 02 '22 14:10

Michael Allan Jackson