七度&光 2012-09-18 14:07 采纳率: 22.2%
浏览 288
已采纳

Npm 安装 vs. 更新-有什么区别?

What is the practical difference between npm install and npm update? When should I use which?

转载于:https://stackoverflow.com/questions/12478679/npm-install-vs-update-whats-the-difference

  • 写回答

3条回答 默认 最新

  • 程序go 2013-11-06 22:26
    关注

    The difference between npm install and npm update handling of package versions specified in package.json:

    {
      "name":          "my-project",
      "version":       "1.0",                             // install   update
      "dependencies":  {                                  // ------------------
        "already-installed-versionless-module":  "*",     // ignores   "1.0" -> "1.1"
        "already-installed-semver-module":       "^1.4.3" // ignores   "1.4.3" -> "1.5.2"
        "already-installed-versioned-module":    "3.4.1"  // ignores   ignores
        "not-yet-installed-versionless-module":  "*",     // installs  installs
        "not-yet-installed-semver-module":       "^4.2.1" // installs  installs
        "not-yet-installed-versioned-module":    "2.7.8"  // installs  installs
      }
    }
    

    Summary: The only big difference is that an already installed module with fuzzy versioning ...

    • gets ignored by npm install
    • gets updated by npm update

    Additionally: install and update by default handle devDependencies differently

    • npm install will install/update devDependencies unless --production flag is added
    • npm update will ignore devDependencies unless --dev flag is added

    Why use npm install at all?

    Because npm install does more when you look besides handling your dependencies in package.json. As you can see in npm install you can ...

    • manually install node-modules
    • set them as global (which puts them in the shell's PATH) using npm install -g <name>
    • install certain versions described by git tags
    • install from a git url
    • force a reinstall with --force
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?