node.js npm update 不做任何事情
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/39758042/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
npm update does not do anything
提问by Elisabeth
When I execute this code in my application folder where the package.json is located:
当我在 package.json 所在的应用程序文件夹中执行此代码时:
npm updateor npm update --save-devit does not do anything.
npm update或者npm update --save-dev它什么都不做。
But when I do npm outdatedis shows many outdated packages.
但是当我这样做时npm outdated会显示许多过时的软件包。
So how do I update all packages?
那么如何更新所有软件包呢?
OS: Win 10 x64
nodejs: 6.2.2
npm:3.10.7
package.json
{
"name": "tgb-frontend",
"version": "0.0.0",
"license": "MIT",
"angular-cli": {},
"scripts": {
"start": "ng serve",
"lint": "tslint \"src/**/*.ts\"",
"test": "ng test",
"pree2e": "webdriver-manager update",
"e2e": "protractor"
},
"private": true,
"dependencies": {
"@angular/common": "2.0.0",
"@angular/compiler": "2.0.0",
"@angular/core": "2.0.0",
"@angular/forms": "2.0.0",
"@angular/http": "2.0.0",
"@angular/platform-browser": "2.0.0",
"@angular/platform-browser-dynamic": "2.0.0",
"@angular/router": "3.0.0",
"core-js": "^2.4.1",
"rxjs": "5.0.0-beta.12",
"ts-helpers": "^1.1.1",
"zone.js": "^0.6.23"
},
"devDependencies": {
"@types/jasmine": "^2.2.30",
"angular-cli": "1.0.0-beta.14",
"codelyzer": "~0.0.26",
"jasmine-core": "2.4.1",
"jasmine-spec-reporter": "2.5.0",
"karma": "1.2.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.0.2",
"karma-remap-istanbul": "^0.2.1",
"protractor": "4.0.5",
"ts-node": "1.2.1",
"tslint": "3.13.0",
"typescript": "2.0.2"
}
}
Running npm update --ddresult in the follow extraction output:
npm update --dd在以下提取输出中运行结果:
npm verb headers 'x-timer': 'S1475099110.490813,VS0,VE0',
npm verb headers vary: 'Accept-Encoding' }
npm verb etag https://registry.npmjs.org/protractor from cache
npm verb get saving protractor to C:\Users\elisabeth\AppData\Roaming\npm-cache\registry.npmjs.org\protractor\.cache.json
npm verb correctMkdir C:\Users\elisabeth\AppData\Roaming\npm-cache correctMkdir already in flight; waiting
npm http 304 https://registry.npmjs.org/zone.js
npm verb headers { date: 'Wed, 28 Sep 2016 21:45:10 GMT',
npm verb headers via: '1.1 varnish',
npm verb headers 'cache-control': 'max-age=300',
npm verb headers etag: '"CEIBQS48U3970DBBLVY9BS6AW"',
npm verb headers age: '128',
npm verb headers connection: 'keep-alive',
npm verb headers 'x-served-by': 'cache-fra1222-FRA',
npm verb headers 'x-cache': 'HIT',
npm verb headers 'x-cache-hits': '1',
npm verb headers 'x-timer': 'S1475099110.490820,VS0,VE0',
npm verb headers vary: 'Accept-Encoding' }
npm verb etag https://registry.npmjs.org/zone.js from cache
npm verb get saving zone.js to C:\Users\elisabeth\AppData\Roaming\npm-cache\registry.npmjs.org\zone.js\.cache.json
npm verb correctMkdir C:\Users\elisabeth\AppData\Roaming\npm-cache correctMkdir already in flight; waiting
npm http 304 https://registry.npmjs.org/karma-chrome-launcher
npm verb headers { date: 'Wed, 28 Sep 2016 21:45:10 GMT',
npm verb headers via: '1.1 varnish',
npm verb headers 'cache-control': 'max-age=300',
npm verb headers etag: '"4F85C0FZBMRDOTDFPHJMQZBM8"',
npm verb headers age: '59',
npm verb headers connection: 'keep-alive',
npm verb headers 'x-served-by': 'cache-fra1231-FRA',
npm verb headers 'x-cache': 'HIT',
npm verb headers 'x-cache-hits': '1',
npm verb headers 'x-timer': 'S1475099110.492537,VS0,VE0',
npm verb headers vary: 'Accept-Encoding' }
npm verb etag https://registry.npmjs.org/karma-chrome-launcher from cache
npm verb get saving karma-chrome-launcher to C:\Users\elisabeth\AppData\Roaming\npm-cache\registry.npmjs.org\karma-chrome-launcher\.cache.json
npm verb correctMkdir C:\Users\elisabeth\AppData\Roaming\npm-cache correctMkdir already in flight; waiting
npm http 304 https://registry.npmjs.org/karma-remap-istanbul
npm verb headers { date: 'Wed, 28 Sep 2016 21:45:10 GMT',
npm verb headers via: '1.1 varnish',
npm verb headers 'cache-control': 'max-age=300',
npm verb headers etag: '"BYUZKVHQIHLVUT104GP509OFK"',
npm verb headers age: '268',
npm verb headers connection: 'keep-alive',
npm verb headers 'x-served-by': 'cache-fra1221-FRA',
npm verb headers 'x-cache': 'HIT',
npm verb headers 'x-cache-hits': '1',
npm verb headers 'x-timer': 'S1475099110.490957,VS0,VE0',
npm verb headers vary: 'Accept-Encoding' }
npm verb etag https://registry.npmjs.org/karma-remap-istanbul from cache
npm verb get saving karma-remap-istanbul to C:\Users\elisabeth\AppData\Roaming\npm-cache\registry.npmjs.org\karma-remap-istanbul\.cache.json
npm verb correctMkdir C:\Users\elisabeth\AppData\Roaming\npm-cache correctMkdir already in flight; waiting
npm http 304 https://registry.npmjs.org/tslint
npm verb headers { date: 'Wed, 28 Sep 2016 21:45:10 GMT',
npm verb headers via: '1.1 varnish',
npm verb headers 'cache-control': 'max-age=300',
npm verb headers etag: '"CWO8LZOC4DK34K142T9LWM1RX"',
npm verb headers age: '10',
npm verb headers connection: 'keep-alive',
npm verb headers 'x-served-by': 'cache-fra1248-FRA',
npm verb headers 'x-cache': 'HIT',
npm verb headers 'x-cache-hits': '1',
npm verb headers 'x-timer': 'S1475099110.490976,VS0,VE0',
npm verb headers vary: 'Accept-Encoding' }
npm verb etag https://registry.npmjs.org/tslint from cache
npm verb get saving tslint to C:\Users\elisabeth\AppData\Roaming\npm-cache\registry.npmjs.org\tslint\.cache.json
npm verb correctMkdir C:\Users\elisabeth\AppData\Roaming\npm-cache correctMkdir already in flight; waiting
npm http 304 https://registry.npmjs.org/jasmine-spec-reporter
npm verb headers { date: 'Wed, 28 Sep 2016 21:45:10 GMT',
npm verb headers via: '1.1 varnish',
npm verb headers 'cache-control': 'max-age=300',
npm verb headers etag: '"1TKJPMC6QAX7DTKI3RCPOWB33"',
npm verb headers age: '59',
npm verb headers connection: 'keep-alive',
npm verb headers 'x-served-by': 'cache-fra1235-FRA',
npm verb headers 'x-cache': 'HIT',
npm verb headers 'x-cache-hits': '1',
npm verb headers 'x-timer': 'S1475099110.496023,VS0,VE0',
npm verb headers vary: 'Accept-Encoding' }
npm verb etag https://registry.npmjs.org/jasmine-spec-reporter from cache
npm verb get saving jasmine-spec-reporter to C:\Users\elisabeth\AppData\Roaming\npm-cache\registry.npmjs.org\jasmine-spec-reporter\.cache.json
npm verb correctMkdir C:\Users\elisabeth\AppData\Roaming\npm-cache correctMkdir already in flight; waiting
npm http 304 https://registry.npmjs.org/typescript
npm verb headers { date: 'Wed, 28 Sep 2016 21:45:10 GMT',
npm verb headers via: '1.1 varnish',
npm verb headers 'cache-control': 'max-age=300',
npm verb headers etag: '"BTWWBQ9R8BXMY0349REWK133W"',
npm verb headers age: '252',
npm verb headers connection: 'keep-alive',
npm verb headers 'x-served-by': 'cache-fra1227-FRA',
npm verb headers 'x-cache': 'HIT',
npm verb headers 'x-cache-hits': '9',
npm verb headers 'x-timer': 'S1475099110.501994,VS0,VE0',
npm verb headers vary: 'Accept-Encoding' }
npm verb etag https://registry.npmjs.org/typescript from cache
npm verb get saving typescript to C:\Users\elisabeth\AppData\Roaming\npm-cache\registry.npmjs.org\typescript\.cache.json
npm verb correctMkdir C:\Users\elisabeth\AppData\Roaming\npm-cache correctMkdir already in flight; waiting
npm http 304 https://registry.npmjs.org/karma-jasmine
npm verb headers { date: 'Wed, 28 Sep 2016 21:45:10 GMT',
npm verb headers via: '1.1 varnish',
npm verb headers 'cache-control': 'max-age=300',
npm verb headers etag: '"36V4PLV1VKGDW8C5GXL8K8BVH"',
npm verb headers age: '211',
npm verb headers connection: 'keep-alive',
npm verb headers 'x-served-by': 'cache-fra1240-FRA',
npm verb headers 'x-cache': 'HIT',
npm verb headers 'x-cache-hits': '1',
npm verb headers 'x-timer': 'S1475099110.498463,VS0,VE0',
npm verb headers vary: 'Accept-Encoding' }
npm verb etag https://registry.npmjs.org/karma-jasmine from cache
npm verb get saving karma-jasmine to C:\Users\elisabeth\AppData\Roaming\npm-cache\registry.npmjs.org\karma-jasmine\.cache.json
npm verb correctMkdir C:\Users\elisabeth\AppData\Roaming\npm-cache correctMkdir already in flight; waiting
npm http 304 https://registry.npmjs.org/karma
npm verb headers { date: 'Wed, 28 Sep 2016 21:45:10 GMT',
npm verb headers via: '1.1 varnish',
npm verb headers 'cache-control': 'max-age=300',
npm verb headers etag: '"9B0FRZQ5V9W9AIXWF98UVSM6C"',
npm verb headers age: '97',
npm verb headers connection: 'keep-alive',
npm verb headers 'x-served-by': 'cache-fra1224-FRA',
npm verb headers 'x-cache': 'HIT',
npm verb headers 'x-cache-hits': '1',
npm verb headers 'x-timer': 'S1475099110.501606,VS0,VE0',
npm verb headers vary: 'Accept-Encoding' }
npm verb etag https://registry.npmjs.org/karma from cache
npm verb get saving karma to C:\Users\elisabeth\AppData\Roaming\npm-cache\registry.npmjs.org\karma\.cache.json
npm verb correctMkdir C:\Users\elisabeth\AppData\Roaming\npm-cache correctMkdir already in flight; waiting
npm http 200 https://registry.npmjs.org/karma-cli
npm verb headers { server: 'CouchDB/1.5.0 (Erlang OTP/R16B03)',
npm verb headers etag: '"BZP1VT7P2AOLYBNMO7N10ESCI"',
npm verb headers 'content-type': 'application/json',
npm verb headers 'content-encoding': 'gzip',
npm verb headers 'cache-control': 'max-age=300',
npm verb headers 'content-length': '2902',
npm verb headers 'accept-ranges': 'bytes',
npm verb headers date: 'Wed, 28 Sep 2016 21:45:10 GMT',
npm verb headers via: '1.1 varnish',
npm verb headers age: '56',
npm verb headers connection: 'keep-alive',
npm verb headers 'x-served-by': 'cache-fra1233-FRA',
npm verb headers 'x-cache': 'HIT',
npm verb headers 'x-cache-hits': '1',
npm verb headers 'x-timer': 'S1475099110.496210,VS0,VE0',
npm verb headers vary: 'Accept-Encoding' }
npm verb get saving karma-cli to C:\Users\elisabeth\AppData\Roaming\npm-cache\registry.npmjs.org\karma-cli\.cache.json
npm verb correctMkdir C:\Users\elisabeth\AppData\Roaming\npm-cache correctMkdir not in flight; initializing
npm http 304 https://registry.npmjs.org/@angular%2fforms
npm verb headers { date: 'Wed, 28 Sep 2016 21:45:10 GMT',
npm verb headers via: '1.1 varnish',
npm verb headers 'cache-control': 'max-age=0',
npm verb headers etag: '"EAEQ3H227F67DKL54RON412OW"',
npm verb headers age: '0',
npm verb headers connection: 'keep-alive',
npm verb headers 'x-served-by': 'cache-fra1238-FRA',
npm verb headers 'x-cache': 'MISS',
npm verb headers 'x-cache-hits': '0',
npm verb headers 'x-timer': 'S1475099110.485421,VS0,VE259',
npm verb headers vary: 'Accept-Encoding' }
npm verb etag https://registry.npmjs.org/@angular%2fforms from cache
npm verb get saving @angular/forms to C:\Users\elisabeth\AppData\Roaming\npm-cache\registry.npmjs.org\_40angular_252fforms\.cache.json
npm verb correctMkdir C:\Users\elisabeth\AppData\Roaming\npm-cache correctMkdir not in flight; initializing
npm http 304 https://registry.npmjs.org/@angular%2fplatform-browser-dynamic
npm verb headers { 'cache-control': 'max-age=0',
npm verb headers 'accept-ranges': 'bytes',
npm verb headers date: 'Wed, 28 Sep 2016 21:45:10 GMT',
npm verb headers via: '1.1 varnish',
npm verb headers connection: 'keep-alive',
npm verb headers 'x-served-by': 'cache-fra1250-FRA',
npm verb headers 'x-cache': 'MISS',
npm verb headers 'x-cache-hits': '0',
npm verb headers 'x-timer': 'S1475099110.475204,VS0,VE419',
npm verb headers vary: 'Accept-Encoding' }
npm verb etag https://registry.npmjs.org/@angular%2fplatform-browser-dynamic from cache
npm verb get saving @angular/platform-browser-dynamic to C:\Users\elisabeth\AppData\Roaming\npm-cache\registry.npmjs.org\_40angular_252fplatform-browser-dynamic\.cache.json
npm verb correctMkdir C:\Users\elisabeth\AppData\Roaming\npm-cache correctMkdir not in flight; initializing
npm http 304 https://registry.npmjs.org/@angular%2fplatform-browser
npm verb headers { date: 'Wed, 28 Sep 2016 21:45:10 GMT',
npm verb headers via: '1.1 varnish',
npm verb headers 'cache-control': 'max-age=0',
npm verb headers etag: '"6KULKVAP2JLLHXUR9G1MKEWBH"',
npm verb headers age: '0',
npm verb headers connection: 'keep-alive',
npm verb headers 'x-served-by': 'cache-fra1247-FRA',
npm verb headers 'x-cache': 'MISS',
npm verb headers 'x-cache-hits': '0',
npm verb headers 'x-timer': 'S1475099110.481265,VS0,VE428',
npm verb headers vary: 'Accept-Encoding' }
npm verb etag https://registry.npmjs.org/@angular%2fplatform-browser from cache
npm verb get saving @angular/platform-browser to C:\Users\elisabeth\AppData\Roaming\npm-cache\registry.npmjs.org\_40angular_252fplatform-browser\.cache.json
npm verb correctMkdir C:\Users\elisabeth\AppData\Roaming\npm-cache correctMkdir not in flight; initializing
[..................] | : verb correctMkdir C:\Users\elisabeth\AppData\Roaming\npm-cache correctMkdir not in npm http 304 https://registry.npmjs.org/@angular%2frouter
npm verb headers { date: 'Wed, 28 Sep 2016 21:45:10 GMT',
npm verb headers via: '1.1 varnish',
npm verb headers 'cache-control': 'max-age=0',
npm verb headers etag: '"E37EYJC1EI89JHFLMFG79P1B1"',
npm verb headers age: '0',
npm verb headers connection: 'keep-alive',
npm verb headers 'x-served-by': 'cache-fra1247-FRA',
npm verb headers 'x-cache': 'MISS',
npm verb headers 'x-cache-hits': '0',
npm verb headers 'x-timer': 'S1475099110.481239,VS0,VE452',
npm verb headers vary: 'Accept-Encoding' }
npm verb etag https://registry.npmjs.org/@angular%2frouter from cache
npm verb get saving @angular/router to C:\Users\elisabeth\AppData\Roaming\npm-cache\registry.npmjs.org\_40angular_252frouter\.cache.json
npm verb correctMkdir C:\Users\elisabeth\AppData\Roaming\npm-cache correctMkdir not in flight; initializing
npm http 304 https://registry.npmjs.org/@types%2fjasmine
npm verb headers { date: 'Wed, 28 Sep 2016 21:45:10 GMT',
npm verb headers via: '1.1 varnish',
npm verb headers 'cache-control': 'max-age=0',
npm verb headers etag: '"5970JWNJE5EMJ1LQCUJLDE51A"',
npm verb headers age: '0',
npm verb headers connection: 'keep-alive',
npm verb headers 'x-served-by': 'cache-fra1249-FRA',
npm verb headers 'x-cache': 'MISS',
npm verb headers 'x-cache-hits': '0',
npm verb headers 'x-timer': 'S1475099110.480305,VS0,VE717',
npm verb headers vary: 'Accept-Encoding' }
npm verb etag https://registry.npmjs.org/@types%2fjasmine from cache
npm verb get saving @types/jasmine to C:\Users\elisabeth\AppData\Roaming\npm-cache\registry.npmjs.org\_40types_252fjasmine\.cache.json
npm verb correctMkdir C:\Users\elisabeth\AppData\Roaming\npm-cache correctMkdir not in flight; initializing
npm http 304 https://registry.npmjs.org/@angular%2fcommon
npm verb headers { date: 'Wed, 28 Sep 2016 21:45:10 GMT',
npm verb headers via: '1.1 varnish',
npm verb headers 'cache-control': 'max-age=0',
npm verb headers etag: '"5T3TIRLH7GIKTLAUE8ASZODQP"',
npm verb headers age: '0',
npm verb headers connection: 'keep-alive',
npm verb headers 'x-served-by': 'cache-fra1237-FRA',
npm verb headers 'x-cache': 'MISS',
npm verb headers 'x-cache-hits': '0',
npm verb headers 'x-timer': 'S1475099110.478583,VS0,VE741',
npm verb headers vary: 'Accept-Encoding' }
npm verb etag https://registry.npmjs.org/@angular%2fcommon from cache
npm verb get saving @angular/common to C:\Users\elisabeth\AppData\Roaming\npm-cache\registry.npmjs.org\_40angular_252fcommon\.cache.json
npm verb correctMkdir C:\Users\elisabeth\AppData\Roaming\npm-cache correctMkdir not in flight; initializing
npm http 304 https://registry.npmjs.org/@angular%2fcompiler
npm verb headers { date: 'Wed, 28 Sep 2016 21:45:10 GMT',
npm verb headers via: '1.1 varnish',
npm verb headers 'cache-control': 'max-age=0',
npm verb headers etag: '"7SNBRHEXD0EH21E7G01GBSPZ0"',
npm verb headers age: '0',
npm verb headers connection: 'keep-alive',
npm verb headers 'x-served-by': 'cache-fra1232-FRA',
npm verb headers 'x-cache': 'MISS',
npm verb headers 'x-cache-hits': '0',
npm verb headers 'x-timer': 'S1475099110.485587,VS0,VE764',
npm verb headers vary: 'Accept-Encoding' }
npm verb etag https://registry.npmjs.org/@angular%2fcompiler from cache
npm verb get saving @angular/compiler to C:\Users\elisabeth\AppData\Roaming\npm-cache\registry.npmjs.org\_40angular_252fcompiler\.cache.json
npm verb correctMkdir C:\Users\elisabeth\AppData\Roaming\npm-cache correctMkdir not in flight; initializing
npm http 304 https://registry.npmjs.org/@angular%2fcore
npm verb headers { date: 'Wed, 28 Sep 2016 21:45:10 GMT',
npm verb headers via: '1.1 varnish',
npm verb headers 'cache-control': 'max-age=0',
npm verb headers etag: '"4J1XWC967WZ1FEYDRY04JS2DN"',
npm verb headers age: '0',
npm verb headers connection: 'keep-alive',
npm verb headers 'x-served-by': 'cache-fra1245-FRA',
npm verb headers 'x-cache': 'MISS',
npm verb headers 'x-cache-hits': '0',
npm verb headers 'x-timer': 'S1475099110.482388,VS0,VE783',
npm verb headers vary: 'Accept-Encoding' }
npm verb etag https://registry.npmjs.org/@angular%2fcore from cache
npm verb get saving @angular/core to C:\Users\elisabeth\AppData\Roaming\npm-cache\registry.npmjs.org\_40angular_252fcore\.cache.json
npm verb correctMkdir C:\Users\elisabeth\AppData\Roaming\npm-cache correctMkdir not in flight; initializing
npm http 304 https://registry.npmjs.org/@angular%2fhttp
npm verb headers { 'cache-control': 'max-age=0',
npm verb headers 'accept-ranges': 'bytes',
npm verb headers date: 'Wed, 28 Sep 2016 21:45:11 GMT',
npm verb headers via: '1.1 varnish',
npm verb headers connection: 'keep-alive',
npm verb headers 'x-served-by': 'cache-fra1230-FRA',
npm verb headers 'x-cache': 'MISS',
npm verb headers 'x-cache-hits': '0',
npm verb headers 'x-timer': 'S1475099110.484580,VS0,VE784',
npm verb headers vary: 'Accept-Encoding' }
npm verb etag https://registry.npmjs.org/@angular%2fhttp from cache
npm verb get saving @angular/http to C:\Users\elisabeth\AppData\Roaming\npm-cache\registry.npmjs.org\_40angular_252fhttp\.cache.json
npm verb correctMkdir C:\Users\elisabeth\AppData\Roaming\npm-cache correctMkdir not in flight; initializing
npm verb outdated not updating @angular/common because it's currently at the maximum version that matches its specified semver range
npm verb outdated not updating @angular/compiler because it's currently at the maximum version that matches its specified semver range
npm verb outdated not updating @angular/core because it's currently at the maximum version that matches its specified semver range
npm verb outdated not updating @angular/forms because it's currently at the maximum version that matches its specified semver range
npm verb outdated not updating @angular/http because it's currently at the maximum version that matches its specified semver range
npm verb outdated not updating @angular/platform-browser because it's currently at the maximum version that matches its specified semver range
npm verb outdated not updating @angular/platform-browser-dynamic because it's currently at the maximum version that matches its specified semver range
npm verb outdated not updating @angular/router because it's currently at the maximum version that matches its specified semver range
npm verb outdated not updating angular-cli because it's currently at the maximum version that matches its specified semver range
npm verb outdated not updating codelyzer because it's currently at the maximum version that matches its specified semver range
npm verb outdated not updating jasmine-core because it's currently at the maximum version that matches its specified semver range
npm verb outdated not updating jasmine-spec-reporter because it's currently at the maximum version that matches its specified semver range
npm verb outdated not updating karma because it's currently at the maximum version that matches its specified semver range
npm verb outdated not updating protractor because it's currently at the maximum version that matches its specified semver range
npm verb outdated not updating ts-node because it's currently at the maximum version that matches its specified semver range
npm verb outdated not updating tslint because it's currently at the maximum version that matches its specified semver range
npm verb outdated not updating typescript because it's currently at the maximum version that matches its specified semver range
npm verb exit [ 0, true ]
npm info ok
回答by Ryan Hamley
The npm update --ddoutput says why at the end:
该npm update --dd输出为什么说在最后:
...not updating @angular/common because it's currently at the maximum version that matches its specified semver range
...not updating @angular/common because it's currently at the maximum version that matches its specified semver range
Look at this specific package, angular/common. You have it set to 2.0.0, which means npm will always fetch that specific version. If you want the package to update, you need to use a semver range. You can view a comprehensive list of semver ranges here, but the most commonly used are probably ~and ^.
看看这个特定的包,angular/common. 您将其设置为2.0.0,这意味着 npm将始终获取该特定版本。如果要更新包,则需要使用 semver 范围。您可以在此处查看 semver 范围的完整列表,但最常用的可能是~和^。
~means that the patch version will update. So if you have version ~1.2.1, it will update to any 1.2.x, but never to 1.3.0.
~表示补丁版本会更新。因此,如果您有版本~1.2.1,它将更新为 any 1.2.x,但永远不会更新1.3.0。
^updates the minor version, so if you have ^1.2.1, it will update to any 1.x.xrelease, but never to 2.0.0.
^更新次要版本,所以如果你有^1.2.1,它会更新到任何1.x.x版本,但永远不会更新到2.0.0.
回答by friederbluemle
If npm outdatedshows outdated packages outsideof the semver range (e.g. a major update), npm updatecannotbe used to update these packages.
如果npm outdated显示超出semver 范围的过时包(例如重大更新),npm update则不能用于更新这些包。
To install the latest version, explicitly specify the package with
要安装最新版本,请明确指定包
npm install [-g] <package>
回答by cuSK
When I was very new to Node.js I didn't knew the following. I'm sharing if it might help you.
当我刚接触 Node.js 时,我不知道以下内容。如果它对你有帮助,我正在分享。
npm version:
npm 版本:
npm --version
Note that following also checks for npm version:
请注意,以下还会检查 npm 版本:
npm --version <packagename> // package name argument is simply ignored
Package version:
包版本:
npm list // at local directory to check local package versions
npm list -g // to check global package versions
回答by Kevin
One more thing to check that could be affecting the way you install packages and ultimately causing this problem is your .npmrc file. Check to see if it has a line like:
要检查的另一件事可能会影响您安装软件包的方式并最终导致此问题是您的 .npmrc 文件。检查它是否有如下一行:
save-exact=true
If it does, then remove it or set it to false. When it is set to true, you get the following behavior:
如果是,则将其删除或将其设置为 false。当它设置为 true 时,您会得到以下行为:
Dependencies saved to package.json using --save, --save-dev or --save-optional will be configured with an exact version rather than using npm's default semver range operator.
使用 --save、--save-dev 或 --save-optional 保存到 package.json 的依赖项将被配置为一个确切的版本,而不是使用 npm 的默认 semver 范围运算符。

