0

When I deploy my node.js server to Heroku it throws the following error:

2018-12-27T10:10:28.370131+00:00 app[web.1]: Error: Cannot find module './lib/utils' 2018-12-27T10:10:28.370137+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:538:15) 2018-12-27T10:10:28.370139+00:00 app[web.1]: at Function.Module._load (module.js:468:25) 2018-12-27T10:10:28.370141+00:00 app[web.1]: at Module.require (module.js:587:17) 2018-12-27T10:10:28.370142+00:00 app[web.1]: at require (internal/module.js:11:18) 2018-12-27T10:10:28.370145+00:00 app[web.1]: at Object. (/app/node_modules/mongodb-core/index.js:5:15) 2018-12-27T10:10:28.370146+00:00 app[web.1]: at Module._compile (module.js:643:30) 2018-12-27T10:10:28.370148+00:00 app[web.1]: at Object.Module._extensions..js (module.js:654:10) 2018-12-27T10:10:28.370149+00:00 app[web.1]: at Module.load (module.js:556:32) 2018-12-27T10:10:28.370151+00:00 app[web.1]: at tryModuleLoad (module.js:499:12) 2018-12-27T10:10:28.370153+00:00 app[web.1]: at Function.Module._load (module.js:491:3)

My node.js server is fully working locally, and saving to the database without any problem. Running npm install locally with my current package.json does create a utils.js file under /lib in the node modules. heroku local web build just fine.

I have been re-initiating my package.json time and time again with no success.

Current package.json is as follows:

{
  "name": "temperature_web_app",
  "version": "1.0.0",
  "main": "server.js",
  "scripts": {
    "start": "node server.js"
  },
  "author": "Simon Rosengren",
  "license": "ISC",
  "dependencies": {
    "body-parser": "^1.18.3",
    "express": "^4.16.4",
    "mongodb": "^3.1.10",
    "mqtt": "^2.18.8"
  },
  "engines": {
    "node": "8.9.4"
  }
}
2
  • You got a hanging "a" after '"start": "node server.js', not sure if that's causing the problem? Commented Dec 27, 2018 at 12:41
  • The "a" was just form a copy/paste mistake. So that wasn't the problem Commented Dec 27, 2018 at 13:05

1 Answer 1

0

Not ignoring the node_modules folder when pushing to heroku master seem to have been the problem.

Removing the node_modules folder and then pushing to master did the trick.

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.