admin管理员组文章数量:1357220
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.
本文标签: Choose Nodejs path when executing npm scriptsStack Overflow
版权声明:本文标题:Choose Node.js path when executing npm scripts - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743995048a2572836.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
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