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

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

  • 写回答

4条回答 默认 最新

  • lrony* 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
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器