npm update不会更新某些软件包

时间:2016-04-20 03:55:16

标签: javascript node.js reactjs npm

最近将React更新为0.15,他们修复了过多的标签生成,我决定更新项目。

问题在于,当我npm update时,它更新为0.14.8并且就是这样。 npm outdated显示:

Package       Current  Wanted        Latest  Location
history        1.17.0  1.17.0         2.1.0  history
react          0.14.8  0.14.8        15.0.1  react
react-dom      0.14.8  0.14.8        15.0.1  react-dom
react-router    1.0.3   1.0.3         2.3.0  react-router
react-select    0.9.1   0.9.1  1.0.0-beta12  react-select

我的package.json看起来像:

"dependencies": {
    "extract-text-webpack-plugin": "^1.0.1",
    "history": "^1.17.0",
    "moment": "^2.11.0",
    "node-sass": "^3.4.2",
    "react": "^0.14.5",
    "react-dom": "^0.14.5",
    "react-recaptcha": "^2.0.1",
    "react-redux": "^4.0.6",
    "react-router": "^1.0.3",
    "react-select": "^0.9.1",
    "redux": "^3.0.5",
    "sass-loader": "^3.1.2"
  }

我尝试将版本更改为0.15.0,但后来出现错误:

npm ERR! notarget No compatible version found: react-dom@'>=0.15.0 <0.16.0'
npm ERR! notarget Valid install targets:
npm ERR! notarget ["0.1.0","0.14.0-beta1","0.14.0-beta2","0.14.0-beta3","0.14.0-rc1","0.14.0","0.14.1","0.14.2","0.14.3","0.14.4","0.14.5","0.14.6","0.15.0-alpha.1","0.14.7","15.0.0-rc.1","15.0.0-rc.2","0.14.8","15.0.0","15.0.1"]

我仍然是npm的新人,很抱歉,如果这个问题很愚蠢。 更新所有软件包的正确方法是什么?

1 个答案:

答案 0 :(得分:5)

在这种情况下,npm update按预期工作。满足插入符依赖"^0.14.5"的最新版本是0.14.8。 在v0.14.8之后,React切换到使用主要版本(参见React blog)。 最新的稳定版现在是15.x而不是0.15.x,因此您应该更新package.json文件:

"dependencies": {
    ...
    "react": "^15.0.1",
    "react-dom": "^15.0.1",
    ...
  }