如何更改 npm 全局安装路径 [英] How to change npm globally installation path

查看:68
本文介绍了如何更改 npm 全局安装路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在执行 npm install -g module 时是否可以更改安装依赖项的位置?我知道它安装在您的 C:/../{name}/Appdata..etc 中,但由于磁盘空间有限,我想更改我的路径.

Is it possible to change where you install your dependencies when doing npm install -g module? I know it installed in your C:/../{name}/Appdata..etc but I want to change the path on mine due to limited disk space.

我已经在外部磁盘上安装了 node.js,这很好并且可以执行 npm 命令,但现在我希望全局依赖项也安装在这个磁盘上.

I've installed node.js on an external disk which is fine and can do npm commands, but now I want the global dependencies to be installed on this disk as well.

有办法吗?

推荐答案

您可以通过以下命令将其配置为新的 PATH -

You can configure it to new PATH by the following command -

npm config set prefix '~/.npm-new-global'

这篇关于如何更改 npm 全局安装路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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