错误的ERR!版本无效:"1"

The*_*mer 11 javascript node.js npm google-cloud-platform package.json

题:

在我的本地机器上执行"节点应用程序"时,一切正常.

但是,当我将项目部署到Google App Engine时,实例被终止,我在日志中发现以下错误:

npm ERR! Invalid version: "1"
Run Code Online (Sandbox Code Playgroud)

我在看:

npm:为什么版本"0.1"无效?

错误的ERR!版本无效:y

如何解决npm"错误:版本无效:"0.1"BUG?

我需要纠正的错误是什么?

部署过程始于 gcloud app deploy --version=deploy

总是以:

ERROR: (gcloud.app.deploy) Error Response: [4] Timed out waiting for the app infrastructure to become healthy.
Run Code Online (Sandbox Code Playgroud)

这是我的package.json


码:

的package.json

{
  "name": "Name",
  "version": "1.0.0",
  "description": "Desc",
  "main": "app.js",
  "engines": {
    "node": "6.9.4",
    "npm": "4.2.0"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node app.js",
    "minify": "html-minifier --input-dir ./viewsCopy --output-dir ./views-minified --collapse-whitespace --html5 --minify-js true"
  },
  "author": "author",
  "license": "copyright",
  "dependencies": {
    "bad-words": "^1.5.1",
    "body-parser": "1.1*.1",
    "connect-flash": "0.1.1",
    "decimal.js": "^9.0.1",
    "ejs": "2.5.5",
    "events": "^1.1.1",
    "express": "4.15.2",
    "express-session": "1.15.2",
    "express-validator": "3.2.0",
    "fast-crc32c": "^1.0.4",
    "firebase": "3.9.0",
    "firebase-admin": "^5.2.1",
    "fs": "0.0.1-security",
    "glob": "7.1.1",
    "helmet": "3.5.0",
    "html-minifier": "^3.5.0",
    "morgan": "1.8.1",
    "multer": "1.3.0",
    "nodemailer": "4.0.0",
    "path": "0.12.7",
    "raven": "^2.0.0",
    "request": "^2.83.0",
    "sanitize-html": "^1.14.1",
    "uglify-js": "^3.0.6"
  }
}
Run Code Online (Sandbox Code Playgroud)

Ish*_*age 8

package.json -> 版本语义可能需要类似于 1.0.0

https://docs.npmjs.com/about-semantic-versioning


sid*_*uko 7

在 package.json 中,“engine”属性允许您阻止在不受支持的 CLI 工具版本上运行的 Node.js 应用程序。

您可以删除或修改这些值。通过快速查看 gcloud 文档,他们使用的是 Node.js (v9.4.0) 中的最新稳定版,该版本与 npm v5.6.0 捆绑在一起。您可以通过在版本前添加大于字符来允许应用程序以现有版本和更高版本运行。

"engines": {
    "node": ">6.9.4",
    "npm": ">4.2.0"
},
Run Code Online (Sandbox Code Playgroud)


小智 7

在我的情况下是

"version": "1"
Run Code Online (Sandbox Code Playgroud)

我已经编辑为

"version": "1.0.0"
Run Code Online (Sandbox Code Playgroud)

它修复了。

  • 我有 `"version": "1.0"` 并编辑为 `"version": "1.0.0"` 并且工作得很好,谢谢 (2认同)