Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nvm is not compatible with the npm config "prefix" option:

I am trying to run another NodeJS version with nvm but getting this error:

$ nvm use v4.2.4  nvm is not compatible with the npm config "prefix" option:     currently set to "/Users/z/.npm-global" Run `npm config delete prefix` or `nvm use --delete-prefix v4.2.4` to unset it. 

I have my prefix set on purpose to avoid sudo npm (see https://docs.npmjs.com/getting-started/fixing-npm-permissions).

Is there any way I can use nvm without losing my prefix for globally installed packages?

like image 692
Dmitri Zaitsev Avatar asked Jan 11 '16 09:01

Dmitri Zaitsev


People also ask

Can we install NVM using npm?

Node Version Manager, more commonly called nvm, is the most popular way to install multiple versions of Node.js, but is only available for Mac/Linux and not supported on Windows. Instead, we recommend installing nvm-windows and then using it to install Node.js and Node Package Manager (npm).

What prefix is npm?

This is the closest parent directory to contain a package. json file or node_modules directory, unless -g is also specified. If -g is specified, this will be the value of the global prefix. See npm config for more detail.

What is NVM and npm?

nvm (Node Version Manager) is a tool that allows you to download and install Node. js. Check if you have it installed via nvm --version . curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.26.1/install.sh | bash. npm (Node Package Manager) is a tool that allows you to install javascript packages.


1 Answers

Delete and Reset the prefix

$ npm config delete prefix  $ npm config set prefix $NVM_DIR/versions/node/v6.11.1 

Note: Change the version number with the one indicated in the error message.

nvm is not compatible with the npm config "prefix" option: currently set to "/usr/local" Run "npm config delete prefix" or "nvm use --delete-prefix v6.11.1 --silent" to unset it.


Credits to @gabfiocchi on Github - "You need to overwrite nvm prefix"

like image 70
Mick Avatar answered Oct 13 '22 23:10

Mick