When running npm run dev
I'd like to have npm
use a specific version of Node. In other words, I'd like to configure this script to use a specific Node path.
To make things even more complicated the npm run dev
actually invokes Angular's ng
CLI. So it's important this works too with the respective Node executable.
I tried setting NODE_PATH
env var before ng serve
, as well as looking for some conduit to put in .npmrc
, but couldn't figure out a way to achieve what I am looking for.
When running npm run dev
I'd like to have npm
use a specific version of Node. In other words, I'd like to configure this script to use a specific Node path.
To make things even more complicated the npm run dev
actually invokes Angular's ng
CLI. So it's important this works too with the respective Node executable.
I tried setting NODE_PATH
env var before ng serve
, as well as looking for some conduit to put in .npmrc
, but couldn't figure out a way to achieve what I am looking for.
1 Answer
Reset to default 1npm
always uses the system-installed Node.js version.
If you want to install and use multiple versions, you need to use a version manager like nvm
.
NODE_PATH
isn't relevant in this situation, as it is used to maintain node_modules
search paths.
make start
which in term will downloadnpm
and put it in.node
subfolder of the project. Then,make
uses thenpm
executable that was downloaded, to run allnpm
scripts. What I achieve, is a user should not worry about if they havenpm
installed locally and what version it is. I knownvm
somehow "solves" this, but I don't like it too much. – LIvanov Commented Mar 30 at 8:41my-node ./node_modules/@angular/cli/bin/ng.js
. This doesn't guarantee that the same "node" will be used through the process, but there's a chance it will work. nvm can affect "node" system-wide, that's its purpose, which this may be undesirable for a user. This is basically a case for containers – Estus Flask Commented Mar 30 at 8:49