0

Today, I get an error when deploy NodeJS app to App Engine (GCP) : can not read property 'bcryptjs' of undefined. NodeJS version is 18.6.0 in my computer and version in app.yaml is nodejs14.

I get some confusing why the library name such as 'bcryptjs' is a property of something. My app works fine on the localhost. It has run on GCP for years and I have deployed hundreds of versions. This is the first time I get this issue. May be some issues in GCP??

Please support. BR

I used following modules in package.json :

"bcryptjs": "^2.4.3",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"fcm-node": "^1.6.1",
"fs": "0.0.1-security",
"jsonwebtoken": "^8.5.1",
"mysql2": "^2.3.3",
"nodemon": "^2.0.4",

Logs on App Engine :

Step #2 - "build": Running "node -v"
Step #2 - "build": v14.21.3
Step #2 - "build": Done "node -v" (36.983411ms)
Step #2 - "build": DEBUG: Current dependency hash: 
"fbe023380dbd3c6d264cb98cba31ad1908ba5b35fadda9db7c38f9ac6e90299c"
Step #2 - "build": DEBUG:   Cache dependency hash: 
"6fb8951fdd91e4be86f269388edd5ae1ff15cd0dc067291faa6a12e6997f1c7b"
Step #2 - "build": ***** CACHE MISS: "npm_modules"
Step #2 - "build": Installing application dependencies.
Step #2 - "build": ----------------------------------------------------- 
---------------------------
Step #2 - "build": Running "node -v"
Step #2 - "build": v14.21.3
Step #2 - "build": Done "node -v" (6.296922ms)
Step #2 - "build": ----------------------------------------------------- 
---------------------------
Step #2 - "build": Running "npm --version"
Step #2 - "build": 6.14.18
Step #2 - "build": Done "npm --version" (213.235522ms)
Step #2 - "build": ----------------------------------------------------- 

Step #2 - "build": Running "npm ci --quiet (NODE_ENV=production)"
Step #2 - "build": npm ERR! Cannot read property 'bcrypt' of undefined
Step #2 - "build": 
Step #2 - "build": npm ERR! A complete log of this run can be found in:
Step #2 - "build": npm ERR!     /www-data-home/.npm/_logs/2023-09- 
21T09_20_53_870Z-debug.log
Step #2 - "build": Done "npm ci --quiet (NODE_ENV=production)" 
(564.629673ms)

I tried deployed many times. I removed the node_modules and re-installed packages. The result is not changed

2
  • Try matching the NodeJS versions between your app.yaml and your local computer which is 18. Commented Sep 21, 2023 at 9:22
  • It works great ! Thanks so muck @RohitKharche. Commented Sep 21, 2023 at 9:39

1 Answer 1

0

Finally, The problem is solved. I changed the version of NodeJS in app.yaml file to runtime : nodejs18. It works great! Thanks so much

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.