21

QUESTION:

When doing "node app" on my local machine, everything works.

But when I deploy my project to the Google App Engine, the instance is killed and I find the following error in my logs:

npm ERR! Invalid version: "1"

I looked at:

npm: Why is a version "0.1" invalid?

npm ERR! Invalid version: y

how to workaround npm "Error: Invalid version: "0.1" BUG?

What is the mistake I need to correct ?

The deployment process started by gcloud app deploy --version=deploy

always ends with:

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

Here is my package.json


CODE:

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"
  }
}
TheProgrammer
  • 1,409
  • 4
  • 24
  • 53

7 Answers7

14

in my case was

"version": "1"

I've edited to

"version": "1.0.0"

and it fixes.

MD Ashik
  • 9,117
  • 10
  • 52
  • 59
Sanya Shvets
  • 152
  • 1
  • 6
  • 2
    I had `"version": "1.0"` and edited to `"version": "1.0.0"` and worked just fine, thanks – Lucas Marra Jan 26 '21 at 11:56
  • Your answer is **not** an answer to the question asked here. You have answered [this question](https://stackoverflow.com/q/16887993). – Henke Apr 20 '22 at 13:36
7

In package.json the 'engine' properties allows you to block the node.js application running on versions of CLI tools which are unsupported.

You can either remove or modify the values. From quickly looking at the gcloud documentation they are using the latest stable from node.js (v9.4.0) which is bundled with npm v5.6.0. You could allow your application to run with existing versions and greater by adding the greater than character before the version.

"engines": {
    "node": ">6.9.4",
    "npm": ">4.2.0"
},
sidhuko
  • 3,274
  • 1
  • 17
  • 22
7

package.json -> version semantics may need to be like 1.0.0

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

Ishan Liyanage
  • 2,237
  • 1
  • 26
  • 25
4

What fixed it for me was deleting node_modules and package-lock.json and reinstalling with npm install

aimuhire
  • 58
  • 4
2

As per the documentation provided over here for node-semver there may be an issue with the dependency packages versions being loaded

Double check these versions or remove all of these and then try, if it works then keep on adding one by one and ultimately when it stops working you know which version numbering is faulty

List is as follows which might be the possible suspects

"body-parser": "1.1*.1",
"fs": "0.0.1-security"
Kushal
  • 1,360
  • 6
  • 16
2

try to replace all dependency version with * , Same with npm version. then run npm install. I am not sure it will work or not but give it try.

Nikhil Savaliya
  • 2,138
  • 4
  • 24
  • 45
1

Please remove package-lock.json file. That will fix a problem.

Cardoso
  • 962
  • 1
  • 12
  • 30