【问题标题】:Difference between 'npm add' and 'npm install --save'?“npm add”和“npm install --save”之间的区别?
【发布时间】:2018-12-30 04:40:12
【问题描述】:

我在网上搜索过,仍然无法得到npm add <package>npm install --save <package> 之间的区别。

谢谢。

【问题讨论】:

    标签: javascript npm npm-install


    【解决方案1】:

    add 只是install 的别名。

    所以唯一的区别是--save,它用依赖关系修改package.json

    $  npm add --help
    
    npm install (with no args, in package dir)
    npm install [<@scope>/]<pkg>
    npm install [<@scope>/]<pkg>@<tag>
    npm install [<@scope>/]<pkg>@<version>
    npm install [<@scope>/]<pkg>@<version range>
    npm install <folder>
    npm install <tarball file>
    npm install <tarball url>
    npm install <git:// url>
    npm install <github username>/<github project>
    
    aliases: i, isntall, add
    common options: [--save-prod|--save-dev|--save-optional] [--save-exact] [--no-save]
    

    【讨论】:

    • 我以前也是这么想的。但正如我所见,当您运行 npm add ... 时,依赖项(package.json)正在更新。
    【解决方案2】:

    npm installadd 是别名。 --save 选项已弃用。

    从 NPM 5 开始,包会自动保存; there is no --save option.

    【讨论】:

      猜你喜欢
      • 2016-01-08
      • 2018-09-16
      • 1970-01-01
      • 2018-07-05
      • 1970-01-01
      • 1970-01-01
      • 2016-02-03
      • 2019-12-31
      • 1970-01-01
      相关资源
      最近更新 更多