如何用另一个文件夹替换 NPM node_module 文件夹? [英] How to replace NPM node_module folder with another folder?
问题描述
默认情况下,NPM 是在node_modules"下安装模块.有没有办法将其更改为例如my_modules?
By default of NPM is installing the modules under "node_modules". Is there a way to change it to be for example "my_modules?
推荐答案
所有节点模块的标准是使用 node_modules
目录.
The standard for all node modules is to use the node_modules
directory.
不要试图违背这个统一标准.
Do not try to go against this uniform standard.
您想通过自定义目录来完成什么?
What are you trying to accomplish by customizing the directory?
注意:
以下命令将安装一个模块到my_project/node_modules/some_module
The following command will install a module to my_project/node_modules/some_module
[~/my_project] $ npm install some_module
如果您想安装模块并使它们在您的系统上全局可用,您可以使用 --global
(-g
) 标志
If you'd like to install modules and have them globally available on your system, you can use the --global
(-g
) flag
[~/my_project] $ npm install -g some_module
使用 -g
标志安装的软件包将安装到 ~/.npm
Packages installed with the -g
flag are installed to ~/.npm
根据您的评论,您可以尝试安装任何包含 package.json
文件的目录
Per your comment, you can attempt to install any directory that contains a package.json
file
[~/my_project] $ npm install /path/to/my/pkg
或者,您可以安装符号链接,而不是将整个模块复制到您的 ~/my_project/node_modules
目录.
Alternatively you can install a symbolic link instead of copying the entire module to your ~/my_project/node_modules
directory.
[~/my_project] $ npm link /path/to/my/pkg
有关此的更多信息:
$ npm help install
$ npm help link
这篇关于如何用另一个文件夹替换 NPM node_module 文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!