NodeJS npm更新不执行任何操作

hrysbysz  于 2022-12-12  发布在  Node.js
关注(0)|答案(7)|浏览(193)

当我在package.json所在的应用程序文件夹中执行以下代码时:
npm updatenpm update --save-dev,它不会执行任何操作。
但是当我做npm outdated的时候,它显示了很多过时的软件包。
那么,如何更新所有软件包呢?

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"
  }
}

运行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
wlsrxk51

wlsrxk511#

npm update --dd输出在最后说明了原因:
...not updating @angular/common because it's currently at the maximum version that matches its specified semver range
看看这个特定的包,angular/common。你把它设置为2.0.0,这意味着npm总是会获取那个特定的版本。如果你想更新这个包,你需要使用一个semver范围。你可以在这里查看一个完整的semver范围列表,但是最常用的可能是~^
~意味着补丁版本将更新。因此,如果您有版本~1.2.1,它将更新到任何1.2.x,但永远不会更新到1.3.0
^更新了次要版本,因此如果您有^1.2.1,它将更新到任何1.x.x发行版,但永远不会更新到2.0.0

bvjxkvbb

bvjxkvbb2#

若要更新,请执行以下步骤:
1.运行npm outdated将允许您检查所有需要更新的软件包。列表将显示每个软件包的当前想要的最新版本。
1.接下来,运行npm update,它会将所有软件包更新到package.json中定义的最新 * 可能 * 版本。例如,如果package.json中的某个软件包的版本为**^2.3.1**,则此软件包将不会更新到2.x.x之后的版本。如果包的版本为**~5.3.2**,则不会更新到5.3.x之后。(要了解语义版本控制,请参阅read this
1.但是,如果您想更新到最新版本,而package.json中的软件包版本阻止您按照上面步骤2中的描述进行更新,该怎么办呢?
a)您可以手动更新package.json中的软件包版本,方法是将软件包的版本更改为您希望的最新值。虽然这样做可能有效,但非常繁琐且容易出错。所以我不推荐这样做。
B)您可以自动更新package.json中的软件包版本。为此,您需要使用以下命令安装npm-check-updates软件包(我通常全局安装此软件包):npm i -g npm-check-updates。完成此操作后,您必须运行ncu -u。这只会将package.json中的软件包版本更新为最新版本。可能会要求您运行npm install以安装可用的最新版本。我建议使用此方法。
1.现在,在package.json中更新软件包的版本后,运行npm update,您的软件包将被更新到最新版本。

pvabu6sv

pvabu6sv3#

如果npm [-g] outdated显示过期的软件包 * 超出 * 永久范围(例如,重大更新),则update命令 * 不能 * 用于更新这些软件包。
要安装最新版本,请使用

npm install [-g] <package>
hivapdat

hivapdat4#

当我刚接触Node.js的时候,我不知道下面的内容。如果它对你有帮助的话,我会和你分享。

  • npm版本:*
npm --version
  • 请注意,以下内容也会检查npm版本:*
npm --version <packagename> // package name argument is simply ignored
  • 软件包版本:*
npm list // at local directory to check local package versions
npm list -g // to check global package versions
dldeef67

dldeef675#

还有一件事需要检查,它可能会影响你安装软件包的方式,并最终导致这个问题是你的.npmrc文件。检查它是否有这样的行:

save-exact=true

如果有,则移除它或将其设为false。当设为true时,会有下列行为:
使用--save、--save-dev或--save-optional保存到package.json的依赖项将被配置为精确的版本,而不是使用npm的默认semver范围操作符。
.npmrc和精确保存

new9mtju

new9mtju6#

使用bash上的一个liner将所有过时的软件包更新到最新版本

npm outdated | cut -d" " -f1 | tail -n +2 | sed 's/$/@latest/' | xargs npm i

如果你使用的是^~,或者是你的前几个版本,那么你可以使用npm update <package-name>cannot获得那个包的下一个主要版本。你可以使用npm outdated来检查你的过时包,并为每个包运行npm install <package-name>@latest,上面的一个程序将为你完成所有这些工作

sycxhyv7

sycxhyv77#

您可以强制更新所有包**,即使它破坏了使用现有包的语义版本控制**。

  • 在重要项目中小心使用,在生产中绝对避免使用。*

我发现这个快捷方式对个人项目很有用。
此软件包将更新package.json中的所有依赖版本,并使用以下install命令安装它们。
npx npm-check-updates -u && npm i

相关问题