如何在Windows上更改NPM安装的默认位置?

时间:2023-01-24 17:07:00

When I install modules with NPM on Windows, it installs them to:

当我在Windows上使用NPM安装模块时,它会将它们安装到:

~/node_modules

I'd like to set change this to an arbitrary path such as:

我想将其更改为任意路径,例如:

c:\dev\repo\node_modules

I've tried

我试过了

npm config set prefix <path>

With various values but none of them seem to work.

有各种各样的价值,但它们似乎都不起作用。

1 个解决方案

#1


4  

As mentioned in the FAQ npm installs modules locally, to avoid dependency conflicts with nesting dependencies. If you really want different projects to reference the same copy you can use npm link.

如FAQ中所述,npm在本地安装模块,以避免与嵌套依赖项的依赖冲突。如果你真的想要不同的项目来引用同一个副本,你可以使用npm链接。

#1


4  

As mentioned in the FAQ npm installs modules locally, to avoid dependency conflicts with nesting dependencies. If you really want different projects to reference the same copy you can use npm link.

如FAQ中所述,npm在本地安装模块,以避免与嵌套依赖项的依赖冲突。如果你真的想要不同的项目来引用同一个副本,你可以使用npm链接。