“Npm install --global"和“--保存"一起? [英] "Npm install --global" and "--save" together?
问题描述
我想知道在 npm install 命令中使用 --global 和 --save 参数是否有意义.例如:
npm install gulp -g -s
据我所知,npm 系统文件夹中没有 package.json,所以我想答案是否定的,但我想清除所有疑问.
npm install
命令不支持全局安装模块并一步将其保存到 package.json.>
然而,有一种方法可以间接地全局安装模块.package.json 支持这样的预安装属性:
脚本":{预安装":npm install -g gulp"}
只要你执行 npm install
,gulp 就会被全局安装.请注意,您的当前用户需要获得写入全局节点模块目录的权限.
I was wondering if makes any sense to use in the npm install command the --global and the --save parameters all together. For example:
npm install gulp -g -s
As far as I know there is no package.json in the npm system folder, so I suppose the answer is "no", but I want to clear all doubt.
The npm install
command does not support installing a module both globally and save it to the package.json in one step.
There is, however, a way to install a module globally indirectly. The package.json supports a preinstall property like so:
"scripts": {
"preinstall": "npm install -g gulp"
}
As soon as you execute npm install
, gulp will be installed globally. Please note that your current user then needs permission to write to your global node module directory.
这篇关于“Npm install --global"和“--保存"一起?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!