Coursera exercises - API Dev week 1 - NodeJS Integration has steps missing around npm deps

I'm working through week 1 of the coursera Apigee course (https://www.coursera.org/learn/api-development-apigee-gcp/supplement/dqYBx/node-js-integration-with-...) - on the final section about nodeJS apps. I've created a "hello world" templated nodeJS API proxy, deployed it to test successfully using the original template code. I've then replaced the index.js code with the snippet from the course, that requires express and request rather than http. I'm seeing errors in the runtime log when I try to run it, similar to this:

Cannot find module 'express'

Function.Module._resolveFilename (module.js:548:15)

I fixed these by adding "express":"latest" to the dependencies section of package.json (something the lab material doesn't mention), and commenting out the import request line, as it isn't needed.

It still doesn't work - finally figured out the other change I needed to make was to override the port number, rather thanvapp.listen(3000), I needed to write app.listen(process.env.PORT || 3000)

So, I've answered my own question, but posting this anyway in the interests of anyone else trying to work their way through this section.

Solved Solved
1 1 221
1 ACCEPTED SOLUTION

Thanks for contributing this information Dave. Sorry about the broken lab instructions.

We are working on reviewing and over-hauling the coursera content currently. The updates should be coming soon.

View solution in original post

1 REPLY 1

Thanks for contributing this information Dave. Sorry about the broken lab instructions.

We are working on reviewing and over-hauling the coursera content currently. The updates should be coming soon.