更改Windows中的node.js模块的默认全局安装目录? [英] Change default global installation directory for node.js modules in Windows?
问题描述
在我的Windows安装中,PATH
包括C:\Program Files\nodejs
,其中可执行文件node.exe
是.我可以从外壳程序以及npm
启动node
.我也希望在C:\Program Files\nodejs
中安装新的可执行文件,但似乎无法实现.
In my windows installation PATH
includes C:\Program Files\nodejs
, where executable node.exe
is. I'm able to launch node
from the shell, as well as npm
. I'd like new executables to be installed in C:\Program Files\nodejs
as well, but it seems impossible to achieve.
设置NODE_PATH
和NODE_MODULES
变量不会更改任何内容:默认情况下,内容仍安装在%appdata%\npm
中.
Setting NODE_PATH
and NODE_MODULES
variables doesn't change anything: things are still installed in %appdata%\npm
by default.
如何更改全局安装路径?
How can I change the global installation path?
推荐答案
您需要阅读的所有内容都是 prefix
更改为c:\Program Files\nodejs
.如果要为所有用户全局更改它,请编辑c:\Program Files\nodejs\npmrc
文件,否则创建/编辑c:\Users\{username}\.npmrc
.
Everything you need is to read npm-folders
documentation. I don't want to start my Win notebook now so I cannot verify it, but you should only change prefix
to c:\Program Files\nodejs
in your config file. If you want to change it globally for all users, edit c:\Program Files\nodejs\npmrc
file, otherwise create/edit c:\Users\{username}\.npmrc
.
但是此更改可能会产生一些副作用,因此请阅读此讨论前.我认为您的想法不是一个好主意.
But this change will have probably some side efects so read this discussion before. I think your idea is not a good one.
这篇关于更改Windows中的node.js模块的默认全局安装目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!