googlecodelabs / feedback

Provide feedback to our codelabs by filing an issue here
18 stars 22 forks source link

[cloud-picadaily-lab2]: test the node code locally #708

Open jabbson opened 4 years ago

jabbson commented 4 years ago

Pic-a-daily: Lab 2 Step 7: Test locally Running npm install; npm start command fails with the following error:

npm ERR! cb() never called!
npm ERR! This is an error with npm itself. Please report this error at:
npm ERR!     <https://npm.community>
npm ERR! A complete log of this run can be found in:
npm ERR!     /home/jbsn/.npm/_logs/2020-03-21T00_09_30_287Z-debug.log
> thumbnail_service@0.0.1 start /home/jbsn/serverless-photosharing-workshop/services/thumbnails
> node index.js
internal/modules/cjs/loader.js:583
    throw err;
    ^
Error: Cannot find module 'express'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
    at Function.Module._load (internal/modules/cjs/loader.js:507:25)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at Object.<anonymous> (/home/jbsn/serverless-photosharing-workshop/services/thumbnails/index.js:14:17)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! thumbnail_service@0.0.1 start: `node index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the thumbnail_service@0.0.1 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /home/jbsn/.npm/_logs/2020-03-21T00_09_30_664Z-debug.log

npm install express command is also required?

glaforge commented 4 years ago

Hmm, I might have to double check that one. Express is listed in the package.json dependencies, so that's strange it wouldn't find it.

glaforge commented 4 years ago

I tried an npm install, and then npm start, and it worked for me, I could start my application. Would it be possible that you have not the right package.json content, where it would be missing express?

glaforge commented 4 years ago

FYI the package.json in the codelabs and in the github repo should look like this:

{
  "name": "thumbnail_service",
  "version": "0.0.1",
  "main": "index.js",
  "scripts": {
    "start": "node index.js"
  },
  "dependencies": {
    "@google-cloud/storage": "^4.0.0",
    "body-parser": "^1.19.0",
    "express": "^4.16.4",
    "bluebird": "^3.5.0",
    "imagemagick": "^0.1.3"
  }
}
jabbson commented 4 years ago

I tried an npm install, and then npm start, and it worked for me, I could start my application. Would it be possible that you have not the right package.json content, where it would be missing express?

I am pretty sure I followed the instructions step by step and didn't experiment at all, but unfortunately I already have the project down and removed. I think this issue can be closed at least until someone confirms and reproduces the issue. Thank you.