“Npm install --global” and “--save” together?

后端 未结 1 1093
被撕碎了的回忆
被撕碎了的回忆 2021-02-05 23:12

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          


        
相关标签:
1条回答
  • 2021-02-05 23:59

    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.

    0 讨论(0)
提交回复
热议问题