Kai Ferrall
Kai Ferrall

Reputation: 91

Heroku build successfull, but application error

I am trying to deploy an app which has a node backend and a react front end. I am using heroku and my code is below. It says there is an error with mongo, I tried re installing my node modules. I dont have much experience with heroku so any input would be great. Thanks in advance. In server.js -

if (process.env.NODE_ENV === "production") {
  app.use(express.static("client/build"));

  app.get("*", (req, res) => {
    res.sendFile(path.resolve(__dirname, "client", "build", "index.html"));
  });
}

In package.json -

{
  "author": "Spotify",
  "name": "web-api-auth-examples",
  "description": "Basic examples of the Spotify authorization flows through OAuth 2",
  "main": "server.js",
  "scripts": {
    "start": "node server.js",
    "client": "npm start --prefix client",
    "heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client"
  },
  "version": "0.0.2",
  "dependencies": {
    "bcryptjs": "^2.4.3",
    "body-parser": "^1.18.3",
    "cors": "^2.8.4",
    "dateformat": "^3.0.3",
    "express": "~4.16.0",
    "jsonwebtoken": "^8.3.0",
    "multer": "^1.3.1",
    "passport": "^0.4.0",
    "passport-jwt": "^4.0.0",
    "querystring": "~0.2.0",
    "request": "~2.83.0",
    "request-promise": "^4.2.2",
    "validator": "^10.4.0"
  }
}

The heroku log -

2018-08-18T03:08:30.415893+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2018-08-18T03:08:30.415896+00:00 app[web.1]: npm ERR! errno 1
2018-08-18T03:08:30.415899+00:00 app[web.1]: npm ERR! web-api-auth-examples@0.0.2 start: `node server.js                    `
2018-08-18T03:08:30.415909+00:00 app[web.1]: npm ERR! Failed at the web-api-auth-examples@0.0.2 start sc                    ript.
2018-08-18T03:08:30.415905+00:00 app[web.1]: npm ERR!
2018-08-18T03:08:30.423862+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2018-08-18T03:08:30.423859+00:00 app[web.1]:
2018-08-18T03:08:30.415901+00:00 app[web.1]: npm ERR! Exit status 1
2018-08-18T03:08:30.415913+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is                     likely additional logging output above.
2018-08-18T03:08:30.423864+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2018-08-18T03_08_30_416Z-debug                    .log
2018-08-18T03:08:30.536987+00:00 heroku[web.1]: State changed from starting to crashed
2018-08-18T03:08:30.539851+00:00 heroku[web.1]: State changed from crashed to starting
2018-08-18T03:08:30.502667+00:00 heroku[web.1]: Process exited with status 1
2018-08-18T03:08:42.074442+00:00 heroku[web.1]: Starting process with command `npm start`
2018-08-18T03:08:45.349152+00:00 app[web.1]:
2018-08-18T03:08:45.349173+00:00 app[web.1]: > node server.js
2018-08-18T03:08:45.349171+00:00 app[web.1]: > web-api-auth-examples@0.0.2 start /app
2018-08-18T03:08:45.349174+00:00 app[web.1]:
2018-08-18T03:08:46.080144+00:00 app[web.1]: module.js:549
2018-08-18T03:08:46.080165+00:00 app[web.1]: throw err;
2018-08-18T03:08:46.080167+00:00 app[web.1]: ^
2018-08-18T03:08:46.080168+00:00 app[web.1]:
2018-08-18T03:08:46.080171+00:00 app[web.1]: Error: Cannot find module 'mongoose'
2018-08-18T03:08:46.080172+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:547:15)
2018-08-18T03:08:46.080174+00:00 app[web.1]: at Function.Module._load (module.js:474:25)

Upvotes: 1

Views: 153

Answers (1)

Hemadri Dasari
Hemadri Dasari

Reputation: 34014

What I understand From your error and given package.json is that you are using mongoose somewhere in your application but mongoose is actually not installed.

Install mongoose to resolve the issue

npm install -s mongoose

Upvotes: 1

Related Questions