By default of NPM is installing the modules under "node_modules". Is there a way to change it to be for example "my_modules?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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?
Note:
The following command will install a module to my_project/node_modules/some_module
[~/my_project] $ npm install some_module
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
Packages installed with the -g
flag are installed to ~/.npm
EDIT
Per your comment, you can attempt to install any directory that contains a package.json
file
[~/my_project] $ npm install /path/to/my/pkg
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
For more info about this:
$ npm help install
$ npm help link