Software Ninja
Software Ninja

Reputation: 83

Heroku node_modules not found

I have a REST API built using Node.js and Express.js. The api works when running locally (tested via postman) and also works with heroku local web.

The problem comes when I deploy it to Heroku. As far I know, it doesnt find node_modules folder. here is the error when viewing Heroku logs.

2018-08-05T23:06:22.543693+00:00 app[web.1]: npm ERR! Failed at the [email protected] start script.
2018-08-05T23:06:22.543859+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2018-08-05T23:06:22.551894+00:00 app[web.1]: 
2018-08-05T23:06:22.552047+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2018-08-05T23:06:22.552153+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2018-08-05T23_06_22_545Z-debug.log
2018-08-05T23:06:22.633382+00:00 heroku[web.1]: Process exited with status 1
2018-08-05T23:06:22.844536+00:00 heroku[web.1]: State changed from starting to crashed

I logged to Heroku bash using heroku run bash and see all my files including node_modules is there. Tried running running yarn dev in the bash (my start script) here is what i get

~ $ yarn dev
yarn run v1.9.4
$ nps dev
/bin/sh: 1: nps: not found
error Command failed with exit code 127.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Here is my package.json file Package.json Here is my package-scripts.js file package-scripts.js

Any help would be greatly appreciated, I literally tried every stackoverflow suggestion but still no luck

Upvotes: 2

Views: 736

Answers (3)

SriMaharshi Manchem
SriMaharshi Manchem

Reputation: 534

Set heroku config:set NPM_CONFIG_PRODUCTION=false and try. Heroku will strip out the packages declared under devDependencies before deploying the application. nps module under devDependencies will not be available.

Upvotes: 2

Ibn
Ibn

Reputation: 11

Check if your package.json file has the dependencies added. I faced the same problem cuz I didnt have the dependencies.

Upvotes: 1

Alex.U
Alex.U

Reputation: 1701

Set NODE_MODULES_CACHE=false in Heroku's config variables

Upvotes: 1

Related Questions