如何确定 npm 包是否有可用的更新版本?

How can I determine if an npm package has a more recent version available?

我发现在我的 package.json 中放置一个不存在的版本会导致包含所有可用选项的错误消息。

例如,我使用了一个不存在的打字包版本。

{
  "name": "ang2-reg",
  "version": "1.0.0",
  "scripts": {
    "postinstall": "npm run typings install",
    "tsc": "tsc",
    "tsc:w": "tsc -w",
    "lite": "lite-server",
    "start": "concurrent \"npm run tsc:w\" \"npm run lite\" ",
    "typings" : "typings"
  },
  "license": "ISC",
  "dependencies": {
    "angular2": "2.0.0-beta.6",
    "systemjs": "0.19.20",
    "es6-promise": "^3.0.2",
    "es6-shim": "^0.33.3",
    "zone.js": "0.5.14"
  },
  "devDependencies": {
    "concurrently": "^1.0.0",
    "lite-server": "^2.1.0",
    "typescript": "^1.8.0.not-there",
    "typings":"^0.6.8"
  }
}

调用命令 "npm install" 后,我收到了这条有用的错误消息:

npm ERR! No compatible version found: typescript@^1.8.0.not-there

然后我得到了所有可用版本的打字稿列表,这真的很有帮助。

我的问题是,如何在不暂存失败的 npm 安装的情况下直接获取可能的打字稿版本列表?

是:

npm view typescript versions

如果您只想要最新版本,请省略 's':

npm view typescript version