更改Windows中的node.js模块的默认全局安装目录? [英] Change default global installation directory for node.js modules in Windows?

查看:247
本文介绍了更改Windows中的node.js模块的默认全局安装目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的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_PATHNODE_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?

推荐答案

您需要阅读的所有内容都是 文档.我不想立即启动Win笔记本,因此无法验证它,但是您只应在配置文件中将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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆