Heroku deployment error crashing app - angularjs

I am trying to deploy an angular app with node.js in the back to heroku and I keep getting these errors. I checked heroku logs and this error was returned.
$ heroku logs
2017-03-28T19:39:19.558737+00:00 app[web.1]: at Function.Module._load (module.js:417:25)
2017-03-28T19:39:19.558740+00:00 app[web.1]: at Object.Module._extensions..js (module.js:579:10)
2017-03-28T19:39:19.558738+00:00 app[web.1]: at Module.require (module.js:497:17)
2017-03-28T19:39:19.558740+00:00 app[web.1]: at Module._compile (module.js:570:32)
2017-03-28T19:39:19.558741+00:00 app[web.1]: at Module.load (module.js:487:32)
2017-03-28T19:39:19.558741+00:00 app[web.1]: at tryModuleLoad (module.js:446:12)
2017-03-28T19:39:19.558742+00:00 app[web.1]: at Function.Module._load (module.js:438:3)
2017-03-28T19:39:19.558744+00:00 app[web.1]: at Module._compile (module.js:570:32)
2017-03-28T19:39:19.558743+00:00 app[web.1]: at Module.require (module.js:497:17)
2017-03-28T19:39:19.558745+00:00 app[web.1]: at Object.Module._extensions..js (module.js:579:10)
2017-03-28T19:39:19.558743+00:00 app[web.1]: at require (internal/module.js:20:19)
2017-03-28T19:39:19.568956+00:00 app[web.1]:
2017-03-28T19:39:19.558744+00:00 app[web.1]: at Object.<anonymous> (/app/bin/www:7:11)
2017-03-28T19:39:19.558746+00:00 app[web.1]: at Module.load (module.js:487:32)
2017-03-28T19:39:19.576891+00:00 app[web.1]: npm ERR! Linux 3.13.0-112-generic
2017-03-28T19:39:19.577955+00:00 app[web.1]: npm ERR! Exit status 1
2017-03-28T19:39:19.578118+00:00 app[web.1]: npm ERR!
2017-03-28T19:39:19.577095+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
2017-03-28T19:39:19.578397+00:00 app[web.1]: npm ERR! Make sure you have the latest version of node.js and npm installed.
2017-03-28T19:39:19.577245+00:00 app[web.1]: npm ERR! node v6.10.1
2017-03-28T19:39:19.577457+00:00 app[web.1]: npm ERR! npm v3.10.10
2017-03-28T19:39:19.577660+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2017-03-28T19:39:19.577817+00:00 app[web.1]: npm ERR! swiping#0.0.0 start: `node bin/www`
2017-03-28T19:39:19.578260+00:00 app[web.1]: npm ERR! Failed at the swiping#0.0.0 start script 'node bin/www'.
2017-03-28T19:39:19.580186+00:00 app[web.1]: npm ERR! Or if that isn't available, you can get their info via:
2017-03-28T19:39:19.578536+00:00 app[web.1]: npm ERR! If you do, this is most likely a problem with the swiping package,
2017-03-28T19:39:19.578674+00:00 app[web.1]: npm ERR! not with npm itself.
2017-03-28T19:39:19.579513+00:00 app[web.1]: npm ERR! Tell the author that this fails on your system:
2017-03-28T19:39:19.579652+00:00 app[web.1]: npm ERR! node bin/www
2017-03-28T19:39:19.580319+00:00 app[web.1]: npm ERR! npm owner ls swiping
2017-03-28T19:39:19.579787+00:00 app[web.1]: npm ERR! You can get information on how to open an issue for this project with:
2017-03-28T19:39:19.580044+00:00 app[web.1]: npm ERR! npm bugs swiping
2017-03-28T19:39:19.584013+00:00 app[web.1]:
2017-03-28T19:39:19.580460+00:00 app[web.1]: npm ERR! There is likely additional logging output above.
2017-03-28T19:39:19.584213+00:00 app[web.1]: npm ERR! Please include the following file with any support request:
2017-03-28T19:39:19.584307+00:00 app[web.1]: npm ERR! /app/npm-debug.log
2017-03-28T19:39:19.665671+00:00 heroku[web.1]: Process exited with status 1
2017-03-28T19:39:19.683203+00:00 heroku[web.1]: State changed from starting to crashed
2017-03-28T19:50:32.379502+00:00 heroku[web.1]: State changed from crashed to starting
2017-03-28T19:50:36.835295+00:00 heroku[web.1]: Starting process with command `npm start`
2017-03-28T19:50:40.588438+00:00 app[web.1]: > swiping#0.0.0 start /app
2017-03-28T19:50:40.588424+00:00 app[web.1]:
2017-03-28T19:50:40.588439+00:00 app[web.1]: > node bin/www
2017-03-28T19:50:40.588439+00:00 app[web.1]:
2017-03-28T19:50:40.884038+00:00 app[web.1]: { Error: ENOENT: no such file or directory, open '.env'
2017-03-28T19:50:40.884053+00:00 app[web.1]: at Error (native)
2017-03-28T19:50:40.884054+00:00 app[web.1]: at Object.fs.openSync (fs.js:641:18)
2017-03-28T19:50:40.884055+00:00 app[web.1]: at Object.fs.readFileSync (fs.js:509:33)
2017-03-28T19:50:40.884056+00:00 app[web.1]: at Object.config (/app/node_modules/dotenv/lib/main.js:30:37)
2017-03-28T19:50:40.884056+00:00 app[web.1]: at Object.<anonymous> (/app/server.js:7:19)
2017-03-28T19:50:40.884057+00:00 app[web.1]: at Module._compile (module.js:570:32)
2017-03-28T19:50:40.884057+00:00 app[web.1]: at Object.Module._extensions..js (module.js:579:10)
2017-03-28T19:50:40.884058+00:00 app[web.1]: at Module.load (module.js:487:32)
2017-03-28T19:50:40.884058+00:00 app[web.1]: at tryModuleLoad (module.js:446:12)
2017-03-28T19:50:40.884060+00:00 app[web.1]: at Function.Module._load (module.js:438:3) errno: -2, code: 'ENOENT', syscall: 'open', path: '.env' }
2017-03-28T19:50:41.499429+00:00 app[web.1]: module.js:471
2017-03-28T19:50:41.499443+00:00 app[web.1]: throw err;
2017-03-28T19:50:41.499444+00:00 app[web.1]: ^
2017-03-28T19:50:41.499445+00:00 app[web.1]:
2017-03-28T19:50:41.499446+00:00 app[web.1]: Error: Cannot find module 'stripe'
2017-03-28T19:50:41.499447+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:469:15)
2017-03-28T19:50:41.499448+00:00 app[web.1]: at Function.Module._load (module.js:417:25)
2017-03-28T19:50:41.499450+00:00 app[web.1]: at Module._compile (module.js:570:32)
2017-03-28T19:50:41.499450+00:00 app[web.1]: at Object.<anonymous> (/app/server.js:23:31)
2017-03-28T19:50:41.499452+00:00 app[web.1]: at Module.load (module.js:487:32)
2017-03-28T19:50:41.499449+00:00 app[web.1]: at require (internal/module.js:20:19)
2017-03-28T19:50:41.499448+00:00 app[web.1]: at Module.require (module.js:497:17)
2017-03-28T19:50:41.499451+00:00 app[web.1]: at Object.Module._extensions..js (module.js:579:10)
2017-03-28T19:50:41.499453+00:00 app[web.1]: at tryModuleLoad (module.js:446:12)
2017-03-28T19:50:41.499453+00:00 app[web.1]: at Function.Module._load (module.js:438:3)
2017-03-28T19:50:41.499454+00:00 app[web.1]: at Module.require (module.js:497:17)
2017-03-28T19:50:41.499454+00:00 app[web.1]: at require (internal/module.js:20:19)
2017-03-28T19:50:41.499455+00:00 app[web.1]: at Object.<anonymous> (/app/bin/www:7:11)
2017-03-28T19:50:41.499456+00:00 app[web.1]: at Module._compile (module.js:570:32)
2017-03-28T19:50:41.499456+00:00 app[web.1]: at Object.Module._extensions..js (module.js:579:10)
2017-03-28T19:50:41.499457+00:00 app[web.1]: at Module.load (module.js:487:32)
2017-03-28T19:50:41.518990+00:00 app[web.1]:
2017-03-28T19:50:41.533527+00:00 app[web.1]: npm ERR! Linux 3.13.0-112-generic
2017-03-28T19:50:41.533975+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
2017-03-28T19:50:41.534366+00:00 app[web.1]: npm ERR! node v6.10.1
2017-03-28T19:50:41.534659+00:00 app[web.1]: npm ERR! npm v3.10.10
2017-03-28T19:50:41.534971+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2017-03-28T19:50:41.535416+00:00 app[web.1]: npm ERR! Exit status 1
2017-03-28T19:50:41.535202+00:00 app[web.1]: npm ERR! swiping#0.0.0 start: `node bin/www`
2017-03-28T19:50:41.536538+00:00 app[web.1]: npm ERR!
2017-03-28T19:50:41.536786+00:00 app[web.1]: npm ERR! Failed at the swiping#0.0.0 start script 'node bin/www'.
2017-03-28T19:50:41.537264+00:00 app[web.1]: npm ERR! If you do, this is most likely a problem with the swiping package,
2017-03-28T19:50:41.537011+00:00 app[web.1]: npm ERR! Make sure you have the latest version of node.js and npm installed.
2017-03-28T19:50:41.538192+00:00 app[web.1]: npm ERR! Tell the author that this fails on your system:
2017-03-28T19:50:41.537489+00:00 app[web.1]: npm ERR! not with npm itself.
2017-03-28T19:50:41.538418+00:00 app[web.1]: npm ERR! node bin/www
2017-03-28T19:50:41.538660+00:00 app[web.1]: npm ERR! You can get information on how to open an issue for this project with:
2017-03-28T19:50:41.538885+00:00 app[web.1]: npm ERR! npm bugs swiping
2017-03-28T19:50:41.539142+00:00 app[web.1]: npm ERR! Or if that isn't available, you can get their info via:
2017-03-28T19:50:41.539657+00:00 app[web.1]: npm ERR! npm owner ls swiping
2017-03-28T19:50:41.539883+00:00 app[web.1]: npm ERR! There is likely additional logging output above.
2017-03-28T19:50:41.545636+00:00 app[web.1]:
2017-03-28T19:50:41.545943+00:00 app[web.1]: npm ERR! Please include the following file with any support request:
2017-03-28T19:50:41.546128+00:00 app[web.1]: npm ERR! /app/npm-debug.log
2017-03-28T19:50:41.644752+00:00 heroku[web.1]: Process exited with status 1
2017-03-28T19:50:41.660900+00:00 heroku[web.1]: State changed from starting to crashed
Any suggestions, I adjusted the package.json to start on node bin/www because that is how I start the app on my local host. There also seems to be a problem with the .env file being seen. And please ignore the errors related to stripe, thank you

Looks like you're missing a Node module by the name of stripe. If you've included it in your devDependencies, Heroku does not install those. You'll have to move it to the dependencies property for it to be properly utilized in your app. You should also remove the .env file from your GitHub repo, as toddg describes in his answer.

Remove your .env from your git repo.
Create a .gitignore file
From the command line: touch .gitignore
open the file you just created (either use vi or your favorite text editor) and add the following line:
.env
Since .env is already tracked you'll need to remove it from being tracked:
git rm --cached .env
Then commit and redeploy to Heroku

Solved problem. Remove all localhost used package.json change the directory to your own app.js or your root js file name. Give ng build. Upload to herokuapp.

Related

Vite + React: sudo npm run build failed

I having issues deploying my production server using Vite + React:
/var/www/html/dev-sp-doc/node_modules/vite/bin/vite.js:2
import { performance } from 'node:perf_hooks'
^
SyntaxError: Unexpected token {
at Module._compile (internal/modules/cjs/loader.js:723:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sp-doc#0.0.0 build: `tsc && vite build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sp-doc#0.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
node v19.5.0
vite ^3.2.5

Heroku failed due to heroku[router]

I have nooooooo idea what happened or how to fix it. But I know the build and deploy succeeded, yet there was an error when it tried to serve on the heroku domain. This is the log
2021-09-23T17:54:03.000000+00:00 app[api]: Build started by user lotusms#outlook.com
2021-09-23T17:57:33.106282+00:00 app[api]: Deploy 311dbfec by user lotusms#outlook.com
2021-09-23T17:57:33.106282+00:00 app[api]: Release v5 created by user lotusms#outlook.com
2021-09-23T17:57:33.643634+00:00 heroku[web.1]: State changed from crashed to starting
2021-09-23T17:57:34.000000+00:00 app[api]: Build succeeded
2021-09-23T17:57:41.831375+00:00 heroku[web.1]: Starting process with command `npm start`
2021-09-23T17:57:42.751649+00:00 app[web.1]:
2021-09-23T17:57:42.751663+00:00 app[web.1]: > luis-portfolio#1.0.0 start /app
2021-09-23T17:57:42.751664+00:00 app[web.1]: > node backend/server.js
2021-09-23T17:57:42.751664+00:00 app[web.1]:
2021-09-23T17:57:42.850572+00:00 app[web.1]: internal/modules/cjs/loader.js:892
2021-09-23T17:57:42.850573+00:00 app[web.1]: throw err;
2021-09-23T17:57:42.850574+00:00 app[web.1]: ^
2021-09-23T17:57:42.850574+00:00 app[web.1]:
2021-09-23T18:11:55.176407+00:00 app[web.1]: Error: Cannot find module 'express-handlebars'
2021-09-23T18:11:55.176408+00:00 app[web.1]: Require stack:
2021-09-23T18:11:55.176408+00:00 app[web.1]: - /app/backend/server.js
2021-09-23T18:11:55.176409+00:00 app[web.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:889:15)
2021-09-23T18:11:55.176409+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:745:27)
2021-09-23T18:11:55.176410+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:961:19)
2021-09-23T18:11:55.176410+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:92:18)
2021-09-23T18:11:55.176410+00:00 app[web.1]: at Object.<anonymous> (/app/backend/server.js:3:25)
2021-09-23T18:11:55.176410+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1072:14)
2021-09-23T18:11:55.176411+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
2021-09-23T18:11:55.176411+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:937:32)
2021-09-23T18:11:55.176411+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:778:12)
2021-09-23T18:11:55.176412+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2021-09-23T18:11:55.176413+00:00 app[web.1]: requireStack: [ '/app/backend/server.js' ]
2021-09-23T18:11:55.183165+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2021-09-23T18:11:55.183332+00:00 app[web.1]: npm ERR! errno 1
2021-09-23T18:11:55.187383+00:00 app[web.1]: npm ERR! luis-portfolio#1.0.0 start: `node backend/server.js`
2021-09-23T18:11:55.187508+00:00 app[web.1]: npm ERR! Exit status 1
2021-09-23T18:11:55.187587+00:00 app[web.1]: npm ERR!
2021-09-23T18:11:55.187645+00:00 app[web.1]: npm ERR! Failed at the luis-portfolio#1.0.0 start script.
2021-09-23T18:11:55.187699+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2021-09-23T18:11:55.193992+00:00 app[web.1]:
2021-09-23T18:11:55.194070+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2021-09-23T18:11:55.194101+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2021-09-23T18_11_55_188Z-debug.log
2021-09-23T18:11:55.308995+00:00 heroku[web.1]: Process exited with status 1
2021-09-23T18:11:55.387625+00:00 heroku[web.1]: State changed from starting to crashed
2021-09-23T18:18:11.000000+00:00 app[api]: Build started by user lotusms#outlook.com
2021-09-23T18:21:37.829987+00:00 app[api]: Deploy 3133e1a6 by user lotusms#outlook.com
2021-09-23T18:21:37.829987+00:00 app[api]: Release v7 created by user lotusms#outlook.com
2021-09-23T18:21:38.000000+00:00 app[api]: Build succeeded
2021-09-23T18:21:38.201741+00:00 heroku[web.1]: State changed from crashed to starting
2021-09-23T18:21:48.297944+00:00 heroku[web.1]: Starting process with command `npm start`
2021-09-23T18:21:49.385182+00:00 app[web.1]:
2021-09-23T18:21:49.385194+00:00 app[web.1]: > luis-portfolio#1.0.0 start /app
2021-09-23T18:21:49.385194+00:00 app[web.1]: > node backend/server.js
2021-09-23T18:21:49.385195+00:00 app[web.1]:
2021-09-23T18:21:49.496716+00:00 app[web.1]: internal/modules/cjs/loader.js:892
2021-09-23T18:21:49.496718+00:00 app[web.1]: throw err;
2021-09-23T18:21:49.496718+00:00 app[web.1]: ^
2021-09-23T18:21:49.496719+00:00 app[web.1]:
2021-09-23T18:21:49.496719+00:00 app[web.1]: Error: Cannot find module 'cors'
2021-09-23T18:21:49.496719+00:00 app[web.1]: Require stack:
2021-09-23T18:21:49.496720+00:00 app[web.1]: - /app/backend/server.js
2021-09-23T18:21:49.496720+00:00 app[web.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:889:15)
2021-09-23T18:21:49.496720+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:745:27)
2021-09-23T18:21:49.496721+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:961:19)
2021-09-23T18:21:49.496721+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:92:18)
2021-09-23T18:21:49.496722+00:00 app[web.1]: at Object.<anonymous> (/app/backend/server.js:5:25)
2021-09-23T18:21:49.496722+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1072:14)
2021-09-23T18:21:49.496722+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
2021-09-23T18:21:49.496723+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:937:32)
2021-09-23T18:21:49.496723+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:778:12)
2021-09-23T18:21:49.496723+00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12) {
2021-09-23T18:21:49.496724+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2021-09-23T18:21:49.496724+00:00 app[web.1]: requireStack: [ '/app/backend/server.js' ]
2021-09-23T18:21:49.496724+00:00 app[web.1]: }
2021-09-23T18:21:49.512189+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2021-09-23T18:21:49.512362+00:00 app[web.1]: npm ERR! errno 1
2021-09-23T18:21:49.515739+00:00 app[web.1]: npm ERR! luis-portfolio#1.0.0 start: `node backend/server.js`
2021-09-23T18:21:49.515768+00:00 app[web.1]: npm ERR! Exit status 1
2021-09-23T18:21:49.515827+00:00 app[web.1]: npm ERR!
2021-09-23T18:21:49.515861+00:00 app[web.1]: npm ERR! Failed at the luis-portfolio#1.0.0 start script.
2021-09-23T18:21:49.515902+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2021-09-23T18:21:49.611964+00:00 app[web.1]:
2021-09-23T18:21:49.612101+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2021-09-23T18:21:49.612151+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2021-09-23T18_21_49_516Z-debug.log
2021-09-23T18:21:49.736450+00:00 heroku[web.1]: Process exited with status 1
2021-09-23T18:21:49.804463+00:00 heroku[web.1]: State changed from starting to crashed
2021-09-23T18:21:51.473081+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=radiant-brook-92705.herokuapp.com request_id=6652a47c-6241-4d4f-a967-ebd6c8db8091 fwd="71.57.243.26" dyno= connect= service= status=503 bytes= protocol=https
Luiss-Mac-mini:luis-portfolio lotusms$ heroku logs
2021-09-23T18:23:37.573784+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2021-09-23T18:23:37.573953+00:00 app[web.1]: npm ERR! errno 1
2021-09-23T18:23:37.577270+00:00 app[web.1]: npm ERR! luis-portfolio#1.0.0 start: `node backend/server.js`
2021-09-23T18:23:37.577315+00:00 app[web.1]: npm ERR! Exit status 1
2021-09-23T18:23:37.577365+00:00 app[web.1]: npm ERR!
2021-09-23T18:23:37.577402+00:00 app[web.1]: npm ERR! Failed at the luis-portfolio#1.0.0 start script.
2021-09-23T18:23:37.577442+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2021-09-23T18:23:37.580907+00:00 app[web.1]:
2021-09-23T18:23:37.580982+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2021-09-23T18:23:37.581018+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2021-09-23T18_23_37_577Z-debug.log
2021-09-23T18:23:37.695597+00:00 heroku[web.1]: Process exited with status 1
2021-09-23T18:23:37.741882+00:00 heroku[web.1]: State changed from starting to crashed
2021-09-23T18:23:37.746297+00:00 heroku[web.1]: State changed from crashed to starting
2021-09-23T18:23:47.676591+00:00 heroku[web.1]: Starting process with command `npm start`
2021-09-23T18:23:48.916311+00:00 app[web.1]:
2021-09-23T18:23:48.916324+00:00 app[web.1]: > luis-portfolio#1.0.0 start /app
2021-09-23T18:23:48.916325+00:00 app[web.1]: > node backend/server.js
2021-09-23T18:23:48.916325+00:00 app[web.1]:
2021-09-23T18:23:49.020052+00:00 app[web.1]: internal/modules/cjs/loader.js:892
2021-09-23T18:23:49.020053+00:00 app[web.1]: throw err;
2021-09-23T18:23:49.020054+00:00 app[web.1]: ^
2021-09-23T18:23:49.020054+00:00 app[web.1]:
Luiss-Mac-mini:luis-portfolio lotusms$
What is going in here?
P.S. It's an app built with React in a client folder, and Express in a backend folder. Then an main package running the following
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon --watch backend --exec node backend/server.js",
"server": "nodemon backend/server.js",
"client": "npm start --prefix client",
"frontend": "npm run start --prefix client",
"dev": "concurrently \"npm run server\" \"npm run start --prefix client\"",
"heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client"
},
Thanks in advance
Well, here's what fixed it for me. First of all this may be different for you if you have a different root architecture than mine. Your package.json and node_modules and dependencies may be in different places. But you can at least use my solution as a reference and adjust accordingly.
Root Struture
node_modules
package.json //we'll call it root-package for reference
- backend
- node_modules
package.json //we'll call it backend-package for reference
server.js
- client
- node_modules
- public
- build
- src
package.json //we'll call it frontend-package for reference
Though my entry is server.js in the backend folder, I am actually entering through an outer wrapping folder so I can keep a separation of concerns between the backend and client.
I moved all my package.json packages installed in devDependencies to the dependencies folder and made sure that my root-package.json served both of my backend-package.json and frontend-package.json concurrently and the directory was correct.
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"client-install": "npm install --prefix client",
"start": "node backend/server.js",
"server": "nodemon backend/server.js",
"client": "npm start --prefix client",
"dev": "concurrently \"npm run server\" \"npm run client\"",
"heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client"
},

internal/modules/cjs/loader.js:892 throw error

I have deployed my react application in heroku. Build was successful. When I try to run the apllication I am getting an Application error. The error is
021-09-05T18:09:02.093946+00:00 heroku[web.1]: Starting process with command `npm start`
2021-09-05T18:09:04.858809+00:00 app[web.1]:
2021-09-05T18:09:04.858836+00:00 app[web.1]: > photoshare#1.0.0 start /app
2021-09-05T18:09:04.858837+00:00 app[web.1]: > node server.js
2021-09-05T18:09:04.858837+00:00 app[web.1]:
2021-09-05T18:09:05.373833+00:00 app[web.1]: internal/modules/cjs/loader.js:892
2021-09-05T18:09:05.373849+00:00 app[web.1]: throw err;
2021-09-05T18:09:05.373850+00:00 app[web.1]:
2021-09-05T18:09:05.373850+00:00 app[web.1]:
2021-09-05T18:09:05.373850+00:00 app[web.1]: Error: Cannot find module './routes/api/users'
2021-09-05T18:09:05.373850+00:00 app[web.1]: Require stack:
2021-09-05T18:09:05.373851+00:00 app[web.1]: - /app/server.js
2021-09-05T18:09:05.373851+00:00 app[web.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:889:15)
2021-09-05T18:09:05.373852+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:745:27)
2021-09-05T18:09:05.373852+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:961:19)
2021-09-05T18:09:05.373853+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:92:18)
2021-09-05T18:09:05.373853+00:00 app[web.1]: at Object.<anonymous> (/app/server.js:5:15)
2021-09-05T18:09:05.373853+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1072:14)
2021-09-05T18:09:05.373853+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
2021-09-05T18:09:05.373854+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:937:32)
2021-09-05T18:09:05.373854+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:778:12)
2021-09-05T18:09:05.373854+00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
2021-09-05T18:09:05.373855+00:00 app[web.1]: at internal/main/run_main_module.js:17:47 {
2021-09-05T18:09:05.373855+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2021-09-05T18:09:05.373855+00:00 app[web.1]: requireStack: [ '/app/server.js' ]
2021-09-05T18:09:05.373856+00:00 app[web.1]: }
2021-09-05T18:09:05.385287+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2021-09-05T18:09:05.385456+00:00 app[web.1]: npm ERR! errno 1
2021-09-05T18:09:05.388896+00:00 app[web.1]: npm ERR! photoshare#1.0.0 start: `node server.js`
2021-09-05T18:09:05.388956+00:00 app[web.1]: npm ERR! Exit status 1
2021-09-05T18:09:05.389019+00:00 app[web.1]: npm ERR!
2021-09-05T18:09:05.389068+00:00 app[web.1]: npm ERR! Failed at the photoshare#1.0.0 start script.
2021-09-05T18:09:05.389117+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2021-09-05T18:09:05.393542+00:00 app[web.1]:
Check this in your code ./routes/api/users. May be you reference it in wrong way.
Or the better is to create and absolute path:
const path = require('path');
const yourAbsolutePath = path.join( __dirname,'./routes/api/users');
make sure ./routes/api/users is well referenced relative to __dirname

Cannot find module '../config/env Failed at 0.1.0 start script

it was working fine yesterday i don't know what happened npm is not starting instead giving the above error.
help me pls..
npm start scripts not working pls someone help me i'm new to this field
Husnains-Mini:~ husnaintahir$ cd ReactApp
Husnains-Mini:ReactApp husnaintahir$ cd react-complete-guide
Husnains-Mini:react-complete-guide husnaintahir$ npm start
> react-complete-guide#0.1.0 st art /Users/husnaintahir/ReactApp/react-complete-guide
> node scripts/start.js
module.js:549
throw err;
^
Error: Cannot find module '../config/env'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/husnaintahir/ReactApp/react-complete-guide/scripts/start.js:15:1)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! react-complete-guide#0.1.0 start: `node scripts/start.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the react-complete-guide#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/husnaintahir/.npm/_logs/2019-05-22T04_42_05_832Z-debug.log
Husnains-Mini:react-complete-guide husnaintahir$

Issues deploying node / react / redux app to heroku

So I'm having some issues with pushing my app to heroku. Locally it runs and builds fine but it crashes when I try to deploy on heroku. Here's the log I'm seeing after deploying to heroku:
2017-05-18T16:56:47.252771+00:00 app[web.1]: npm ERR! If you do, this is most likely a problem with the pluralsight-redux-starter package,
2017-05-18T16:56:47.252849+00:00 app[web.1]: npm ERR! not with npm itself.
2017-05-18T16:56:47.252939+00:00 app[web.1]: npm ERR! Tell the author that this fails on your system:
2017-05-18T16:56:47.253015+00:00 app[web.1]: npm ERR! npm run build:html
2017-05-18T16:56:47.253089+00:00 app[web.1]: npm ERR! You can get information on how to open an issue for this project with:
2017-05-18T16:56:47.253159+00:00 app[web.1]: npm ERR! npm bugs pluralsight-redux-starter
2017-05-18T16:56:47.253227+00:00 app[web.1]: npm ERR! Or if that isn't available, you can get their info via:
2017-05-18T16:56:47.253304+00:00 app[web.1]: npm ERR! npm owner ls pluralsight-redux-starter
2017-05-18T16:56:47.253382+00:00 app[web.1]: npm ERR! There is likely additional logging output above.
2017-05-18T16:56:47.256870+00:00 app[web.1]:
2017-05-18T16:56:47.257025+00:00 app[web.1]: npm ERR! Please include the following file with any support request:
2017-05-18T16:56:47.257079+00:00 app[web.1]: npm ERR! /app/npm-debug.log
2017-05-18T16:56:47.345310+00:00 heroku[web.1]: State changed from starting to crashed
2017-05-18T16:56:47.336090+00:00 heroku[web.1]: Process exited with status 1
2017-05-18T16:55:58.000000+00:00 app[api]: Build succeeded
2017-05-18T16:59:46.000000+00:00 app[api]: Build started by user dgravelle54#gmail.com
2017-05-18T17:00:08.286603+00:00 app[api]: Release v4 created by user dgravelle54#gmail.com
2017-05-18T17:00:08.286603+00:00 app[api]: Deploy 8f4c395a by user dgravelle54#gmail.com
2017-05-18T17:00:08.618011+00:00 heroku[web.1]: State changed from crashed to starting
2017-05-18T16:59:46.000000+00:00 app[api]: Build succeeded
2017-05-18T17:00:11.772019+00:00 heroku[web.1]: Starting process with command `npm run build`
2017-05-18T17:00:14.380808+00:00 app[web.1]:
2017-05-18T17:00:14.380822+00:00 app[web.1]: > pluralsight-redux-starter#1.0.0 prebuild /app
2017-05-18T17:00:14.380823+00:00 app[web.1]: > npm run build:html
2017-05-18T17:00:14.380823+00:00 app[web.1]:
2017-05-18T17:00:15.182395+00:00 app[web.1]:
2017-05-18T17:00:15.182406+00:00 app[web.1]: > pluralsight-redux-starter#1.0.0 build:html /app
2017-05-18T17:00:15.182407+00:00 app[web.1]: > babel-node tools/buildHtml.js
2017-05-18T17:00:15.182408+00:00 app[web.1]:
2017-05-18T17:00:16.180115+00:00 app[web.1]: /app/node_modules/babel-core/lib/transformation/file/logger.js:41
2017-05-18T17:00:16.180126+00:00 app[web.1]: throw new Constructor(this._buildMessage(msg));
2017-05-18T17:00:16.180127+00:00 app[web.1]: ^
2017-05-18T17:00:16.180128+00:00 app[web.1]:
2017-05-18T17:00:16.180129+00:00 app[web.1]: ReferenceError: [BABEL] /app/tools/buildHtml.js: Unknown option: base.Children. Check out http://babeljs.io/docs/usage/options/ for more information about options.
2017-05-18T17:00:16.180131+00:00 app[web.1]: A common cause of this error is the presence of a configuration options object without the corresponding preset name. Example:
2017-05-18T17:00:16.180131+00:00 app[web.1]:
2017-05-18T17:00:16.180129+00:00 app[web.1]:
2017-05-18T17:00:16.180132+00:00 app[web.1]: Invalid:
2017-05-18T17:00:16.180133+00:00 app[web.1]: `{ presets: [{option: value}] }`
2017-05-18T17:00:16.180134+00:00 app[web.1]: Valid:
2017-05-18T17:00:16.180134+00:00 app[web.1]: `{ presets: [['presetName', {option: value}]] }`
2017-05-18T17:00:16.180135+00:00 app[web.1]:
2017-05-18T17:00:16.180137+00:00 app[web.1]: at Logger.error (/app/node_modules/babel-core/lib/transformation/file/logger.js:41:11)
2017-05-18T17:00:16.180136+00:00 app[web.1]: For more detailed information on preset configuration, please see http://babeljs.io/docs/plugins/#pluginpresets-options.
2017-05-18T17:00:16.180137+00:00 app[web.1]: at OptionManager.mergeOptions (/app/node_modules/babel-core/lib/transformation/file/options/option-manager.js:226:20)
2017-05-18T17:00:16.180138+00:00 app[web.1]: at OptionManager.init (/app/node_modules/babel-core/lib/transformation/file/options/option-manager.js:368:12)
2017-05-18T17:00:16.180139+00:00 app[web.1]: at File.initOptions (/app/node_modules/babel-core/lib/transformation/file/index.js:212:65)
2017-05-18T17:00:16.180140+00:00 app[web.1]: at new File (/app/node_modules/babel-core/lib/transformation/file/index.js:135:24)
2017-05-18T17:00:16.180141+00:00 app[web.1]: at Pipeline.transform (/app/node_modules/babel-core/lib/transformation/pipeline.js:46:16)
2017-05-18T17:00:16.180142+00:00 app[web.1]: at compile (/app/node_modules/babel-register/lib/node.js:118:20)
2017-05-18T17:00:16.180142+00:00 app[web.1]: at loader (/app/node_modules/babel-register/lib/node.js:144:14)
2017-05-18T17:00:16.180143+00:00 app[web.1]: at Object.require.extensions.(anonymous function) [as .js] (/app/node_modules/babel-register/lib/node.js:154:7)
2017-05-18T17:00:16.180141+00:00 app[web.1]: at Object.transformFileSync (/app/node_modules/babel-core/lib/api/node.js:152:10)
2017-05-18T17:00:16.204296+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "run" "build:html"
2017-05-18T17:00:16.204685+00:00 app[web.1]: npm ERR! npm v3.10.10
2017-05-18T17:00:16.204883+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2017-05-18T17:00:16.193941+00:00 app[web.1]:
2017-05-18T17:00:16.205084+00:00 app[web.1]: npm ERR! pluralsight-redux-starter#1.0.0 build:html: `babel-node tools/buildHtml.js`
2017-05-18T17:00:16.204007+00:00 app[web.1]: npm ERR! Linux 3.13.0-112-generic
2017-05-18T17:00:16.204494+00:00 app[web.1]: npm ERR! node v6.10.3
2017-05-18T17:00:16.205216+00:00 app[web.1]: npm ERR! Exit status 1
2017-05-18T17:00:16.205385+00:00 app[web.1]: npm ERR!
2017-05-18T17:00:16.205521+00:00 app[web.1]: npm ERR! Failed at the pluralsight-redux-starter#1.0.0 build:html script 'babel-node tools/buildHtml.js'.
2017-05-18T17:00:16.205654+00:00 app[web.1]: npm ERR! Make sure you have the latest version of node.js and npm installed.
2017-05-18T17:00:16.205790+00:00 app[web.1]: npm ERR! If you do, this is most likely a problem with the pluralsight-redux-starter package,
2017-05-18T17:00:16.205926+00:00 app[web.1]: npm ERR! not with npm itself.
2017-05-18T17:00:16.206069+00:00 app[web.1]: npm ERR! Tell the author that this fails on your system:
2017-05-18T17:00:16.206205+00:00 app[web.1]: npm ERR! babel-node tools/buildHtml.js
2017-05-18T17:00:16.206343+00:00 app[web.1]: npm ERR! You can get information on how to open an issue for this project with:
2017-05-18T17:00:16.206474+00:00 app[web.1]: npm ERR! npm bugs pluralsight-redux-starter
2017-05-18T17:00:16.206616+00:00 app[web.1]: npm ERR! Or if that isn't available, you can get their info via:
2017-05-18T17:00:16.206746+00:00 app[web.1]: npm ERR! npm owner ls pluralsight-redux-starter
2017-05-18T17:00:16.206883+00:00 app[web.1]: npm ERR! There is likely additional logging output above.
2017-05-18T17:00:16.210443+00:00 app[web.1]:
2017-05-18T17:00:16.210851+00:00 app[web.1]: npm ERR! Please include the following file with any support request:
2017-05-18T17:00:16.210971+00:00 app[web.1]: npm ERR! /app/npm-debug.log
2017-05-18T17:00:16.222137+00:00 app[web.1]:
2017-05-18T17:00:16.229747+00:00 app[web.1]: npm ERR! Linux 3.13.0-112-generic
2017-05-18T17:00:16.230016+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "run" "build"
2017-05-18T17:00:16.230230+00:00 app[web.1]: npm ERR! node v6.10.3
2017-05-18T17:00:16.230422+00:00 app[web.1]: npm ERR! npm v3.10.10
2017-05-18T17:00:16.230611+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2017-05-18T17:00:16.230764+00:00 app[web.1]: npm ERR! pluralsight-redux-starter#1.0.0 prebuild: `npm run build:html`
2017-05-18T17:00:16.230889+00:00 app[web.1]: npm ERR! Exit status 1
2017-05-18T17:00:16.231035+00:00 app[web.1]: npm ERR!
2017-05-18T17:00:16.231171+00:00 app[web.1]: npm ERR! Failed at the pluralsight-redux-starter#1.0.0 prebuild script 'npm run build:html'.
2017-05-18T17:00:16.231297+00:00 app[web.1]: npm ERR! Make sure you have the latest version of node.js and npm installed.
2017-05-18T17:00:16.231428+00:00 app[web.1]: npm ERR! If you do, this is most likely a problem with the pluralsight-redux-starter package,
2017-05-18T17:00:16.231554+00:00 app[web.1]: npm ERR! not with npm itself.
2017-05-18T17:00:16.231697+00:00 app[web.1]: npm ERR! Tell the author that this fails on your system:
2017-05-18T17:00:16.231827+00:00 app[web.1]: npm ERR! npm run build:html
2017-05-18T17:00:16.231955+00:00 app[web.1]: npm ERR! You can get information on how to open an issue for this project with:
2017-05-18T17:00:16.232183+00:00 app[web.1]: npm ERR! npm bugs pluralsight-redux-starter
2017-05-18T17:00:16.232315+00:00 app[web.1]: npm ERR! Or if that isn't available, you can get their info via:
2017-05-18T17:00:16.232440+00:00 app[web.1]: npm ERR! npm owner ls pluralsight-redux-starter
2017-05-18T17:00:16.232578+00:00 app[web.1]: npm ERR! There is likely additional logging output above.
2017-05-18T17:00:16.236064+00:00 app[web.1]:
2017-05-18T17:00:16.236264+00:00 app[web.1]: npm ERR! Please include the following file with any support request:
2017-05-18T17:00:16.236373+00:00 app[web.1]: npm ERR! /app/npm-debug.log
2017-05-18T17:00:16.327400+00:00 heroku[web.1]: Process exited with status 1
2017-05-18T17:00:16.337382+00:00 heroku[web.1]: State changed from starting to crashed
Here's a link to my current repo.
https://github.com/dgravelle/magic-redux
I've gone through a bunch of iterations now trying to get this working on heroku but I've had no success. If anyone could shed some light on the issue here I'd greatly appreciate it. Thanks!
on Heroku, you are not a root administrator, it means that you don't have the write permission.
if you want to run your server on heroku, I think you can try to bundle your file in your local.

Resources