leojacoby
leojacoby

Reputation: 85

heroku app crashes because of missing module, but works on localhost

I have an app that I successfully deployed to heroku, but when I try to access it, I get this screen... enter image description here

The log says the following...enter image description here

The error I believe is causing the issue is Error: Cannot find module 'mongoose'.

Here is my package.json for reference...

{
  "name": "ovo",
  "version": "1.0.0",
  "description": "see and sort OVO in real time!",
  "main": "server.js",
  "scripts": {
    "build": "webpack --config webpack.prod.config.js",
    "dev": "concurrently -k \"npm run frontend\" \"npm run backend\"",
    "frontend": "webpack -d --watch",
    "backend": "nodemon server.js",
    "start": "npm run build && NODE_ENV=production node server.js",
    "test": "mocha --compilers js:babel-core/register ./test/**/*.js --require ignore-styles"
  },
  "engines": {
    "node": "6.11.0",
    "npm": "5.0.3"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/leojacoby/ovo.git"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "axios": "^0.17.1",
    "babel-core": "^6.24.1",
    "babel-loader": "^6.4.1",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-react": "^6.24.1",
    "css-loader": "^0.28.0",
    "enzyme": "^2.8.1",
    "expect": "^1.20.2",
    "express": "^4.15.2",
    "immutability-helper": "^2.6.5",
    "mocha": "^3.2.0",
    "mongoose": "^5.4.0",
    "node-sass": "^4.5.2",
    "prop-types": "^15.6.0",
    "rc-slider": "^8.6.0",
    "rc-tooltip": "^3.7.0",
    "react": "^15.5.4",
    "react-addons-update": "^15.6.2",
    "react-bootstrap-table": "^4.3.1",
    "react-bootstrap-table-next": "^0.1.3",
    "react-dom": "^15.5.4",
    "react-rangeslider": "^2.2.0",
    "react-redux": "^5.0.5",
    "redux": "^3.7.2",
    "redux-devtools": "^3.4.0",
    "redux-devtools-dock-monitor": "^1.1.2",
    "redux-devtools-log-monitor": "^1.3.0",
    "sass-loader": "^6.0.3",
    "style-loader": "^0.16.1",
    "webpack": "^2.3.3"
  },
  "devDependencies": {
    "babel-eslint": "^7.2.2",
    "concurrently": "^3.5.0",
    "eslint": "^3.19.0",
    "eslint-loader": "^1.9.0",
    "eslint-plugin-jsx-a11y": "^4.0.0",
    "eslint-plugin-react": "^6.10.3",
    "eslint-watch": "^3.1.0",
    "ignore-styles": "^5.0.1",
    "nodemon": "^1.11.0",
    "react-addons-test-utils": "^15.5.1",
    "react-test-renderer": "^15.5.4",
    "webpack-dev-middleware": "^1.10.1",
    "webpack-dev-server": "^2.4.2",
    "webpack-hot-middleware": "^2.18.0"
  },
  "bugs": {
    "url": "https://github.com/leojacoby/ovo/issues"
  },
  "homepage": "https://github.com/leojacoby/ovo#readme",
  "directories": {
    "test": "test"
  },
  "keywords": []
}

The 'mongoose' npm package is in my package.json, and everything works just fine when I run it on my localhost. Please let me know if you want any more information and thank you for reading!

Upvotes: 2

Views: 589

Answers (2)

leojacoby
leojacoby

Reputation: 85

Turns out I hadn't connected my github to my heroku. I was pushing to github but it was not updating heroku so I kept experiencing the same errors. This is what I had to enable in heroku and then my edits actually manifested in the heroku. enter image description here

An alternative is to just type in git push heroku master into the terminal everytime.

The last thing I had to do was type in heroku config:set MONGODB_URI='mongodb://<name>:<password>@ds123050.mlab.com:23050/ovodb' into the terminal for heroku to access my environmental variable.

Upvotes: 1

mehta-rohan
mehta-rohan

Reputation: 1341

Are you pushing node_modules in your code? If yes try to delete that folder and let Heroku install all modules all over again.

Upvotes: 0

Related Questions