Matloob
Matloob

Reputation: 125

Getting "Cannot find module '/app/dist'" error on deploying to Heroku

I have the following script in my package.json:

  "scripts": {
    "dev": "nodemon server --exec babel-node --presets es2015,stage-2",
    "build": "babel ./server -d ./dist",
    "start": "node ./dist",
    "heroku-postbuild": "cd react-ui/ && npm install && npm install    --only=dev --no-shrinkwrap && npm run build"
  },

On deploying to Heroku I get the following error

Error: Cannot find module '/app/dist'

On local npm run dev, npm run build, and npm run start work fine.

Where is it getting the /app folder? How to fix this?

Thanks Matloob

Upvotes: 5

Views: 13008

Answers (2)

Aihab Gmati
Aihab Gmati

Reputation: 28

Try this :

"start:heroku": "node dist/YOUR-APP-NAME/server/main.js",

Upvotes: 0

tuan.tran
tuan.tran

Reputation: 1881

You should build your app npm run build before deploy to heroku. It will run heroku-postbuild first then start your app.

Upvotes: 4

Related Questions