A few days ago I added a schema file to my website folder so I could use MongoDB with the website. On the surface everything has worked fine but when I deployed the website to Heroku I get the next lines of error on the logs:
2022-06-04T07:14:38.698455+00:00 app[web.1]: node:internal/modules/cjs/loader:936
2022-06-04T07:14:38.698560+00:00 app[web.1]: throw err;
2022-06-04T07:14:38.698560+00:00 app[web.1]: ^
2022-06-04T07:14:38.698560+00:00 app[web.1]: Error: Cannot find module './../models/anime
2022-06-04T07:14:38.698561+00:00 app[web.1]: Require stack:
2022-06-04T07:14:38.698561+00:00 app[web.1]: - /app/routes/watch.js
2022-06-04T07:14:38.698561+00:00 app[web.1]: - /app/app.js
2022-06-04T07:14:38.698563+00:00 app[web.1]: at Function.Module._resolveFilename
2022-06-04T07:14:38.698577+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2022-06-04T07:14:38.698577+00:00 app[web.1]: requireStack: [ '/app/routes/watch.js', '/app/app.js']
Related
Basically, I'm working on a school project -- currently trying to test the login page. I'm using Heroku to deploy this project, but I keep getting the below error. I'm wondering if it has something to do with index.js? My Procfile has the line:
web: node src/[app name].js
Note: [app name] isn't the actual app name. I replaced it for privacy reasons.
2022-10-22T17:19:11.562569+00:00 app[web.1]: Error: Cannot find module '/app/src/[app name].js'
2022-10-22T17:19:11.562570+00:00 app[web.1]: at Function.Module._resolveFilename (node:internal/modules/cjs/loader:985:15)
2022-10-22T17:19:11.562570+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:833:27)
2022-10-22T17:19:11.562570+00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
2022-10-22T17:19:11.562571+00:00 app[web.1]: at node:internal/main/run_main_module:22:47 {
2022-10-22T17:19:11.562571+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2022-10-22T17:19:11.562571+00:00 app[web.1]: requireStack: []
2022-10-22T17:19:11.562572+00:00 app[web.1]: }
I'm trying to deploy my sapper/svelte app to heroku but getting 'Error: Cannot find module 'polka'' this error. Interesting thing is that, it was perfectly fine and working. My package.json is correct and I am not checking my modules into git either. I tried disabling caching but it is no good. Anyone have any ideas?
2020-09-16T16:04:44.083385+00:00 app[web.1]: Error: Cannot find module 'polka'
2020-09-16T16:04:44.083386+00:00 app[web.1]: Require stack:
2020-09-16T16:04:44.083386+00:00 app[web.1]: - /app/__sapper__/build/server/server.js
2020-09-16T16:04:44.083386+00:00 app[web.1]: - /app/__sapper__/build/index.js
2020-09-16T16:04:44.083387+00:00 app[web.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
2020-09-16T16:04:44.083392+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:841:27)
2020-09-16T16:04:44.083392+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:1025:19)
2020-09-16T16:04:44.083393+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:72:18)
2020-09-16T16:04:44.083393+00:00 app[web.1]: at Object.<anonymous> (/app/__sapper__/build/server/server.js:4:13)
2020-09-16T16:04:44.083394+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1137:30)
2020-09-16T16:04:44.083394+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
2020-09-16T16:04:44.083394+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:985:32)
2020-09-16T16:04:44.083395+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:878:14)
2020-09-16T16:04:44.083395+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:1025:19) {
2020-09-16T16:04:44.083396+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2020-09-16T16:04:44.083396+00:00 app[web.1]: requireStack: [
2020-09-16T16:04:44.083397+00:00 app[web.1]: '/app/__sapper__/build/server/server.js',
2020-09-16T16:04:44.083397+00:00 app[web.1]: '/app/__sapper__/build/index.js'
2020-09-16T16:04:44.083397+00:00 app[web.1]: ]
2020-09-16T16:04:44.083398+00:00 app[web.1]: }
It turns out polka's version on my package.json was set to 'next'. So I changed it to it latest stable version and deleted package.lock.json file and ran 'npm install' to create a new lock file and then pushed it to heroku. Works perfectly fine.
I can run node index.js from the directly from the command line but when I run the start script that has the same command I get an error.
Here is the relative server info:
const PORT = process.env.NODE || 3000
app.listen(PORT, () => console.log(`Server running on ${PORT}`))
Here is the package.json script:
"scripts": {
"start": "node index.js"
},
Here is the terminal output ran from the project root running it without the script:
> node index.js
Server running on port 3000
Here is the terminal output running it with the script:
>yarn start
yarn run v1.10.1
$ node index.js
events.js:183
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE /usr/local/bin/node
at Server.setupListenHandle [as _listen2] (net.js:1343:19)
at listenInCluster (net.js:1401:12)
at Server.listen (net.js:1496:5)
at Function.listen (/Users/mmelv/Workspace/Projects/Reportably/server/node_modules/express/lib/application.js:618:24)
at Object.<anonymous> (/Users/mmelv/Workspace/Projects/Reportably/server/index.js:29:5)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Function.Module.runMain (module.js:694:10)
at startup (bootstrap_node.js:204:16)
at bootstrap_node.js:625:3
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
This has boggled me for hours. I've tried sudo killall node, lsof -i tcp:3000 returns nothing. I've reinstalled and upgraded node.
Also, I get the same error when I try to deploy it to Heroku:
2018-10-07T15:47:56.000000+00:00 app[api]: Build succeeded
2018-10-07T15:47:58.569471+00:00 heroku[web.1]: Starting process with command `npm start`
2018-10-07T15:48:01.927982+00:00 app[web.1]:
2018-10-07T15:48:01.928007+00:00 app[web.1]: > server#1.0.0 start /app
2018-10-07T15:48:01.928009+00:00 app[web.1]: > node index.js
2018-10-07T15:48:01.928010+00:00 app[web.1]:
2018-10-07T15:48:02.936929+00:00 app[web.1]: events.js:183
2018-10-07T15:48:02.936974+00:00 app[web.1]: throw er; // Unhandled 'error' event
2018-10-07T15:48:02.936976+00:00 app[web.1]: ^
2018-10-07T15:48:02.936977+00:00 app[web.1]:
2018-10-07T15:48:02.936979+00:00 app[web.1]: Error: listen EADDRINUSE /app/.heroku/node/bin/node
2018-10-07T15:48:02.936981+00:00 app[web.1]: at Object._errnoException (util.js:992:11)
2018-10-07T15:48:02.936982+00:00 app[web.1]: at _exceptionWithHostPort (util.js:1014:20)
2018-10-07T15:48:02.936984+00:00 app[web.1]: at Server.setupListenHandle [as _listen2] (net.js:1338:19)
2018-10-07T15:48:02.936985+00:00 app[web.1]: at listenInCluster (net.js:1396:12)
2018-10-07T15:48:02.936987+00:00 app[web.1]: at Server.listen (net.js:1491:5)
2018-10-07T15:48:02.936989+00:00 app[web.1]: at Function.listen (/app/node_modules/express/lib/application.js:618:24)
2018-10-07T15:48:02.936990+00:00 app[web.1]: at Object.<anonymous> (/app/index.js:29:5)
2018-10-07T15:48:02.936992+00:00 app[web.1]: at Module._compile (module.js:652:30)
2018-10-07T15:48:02.936993+00:00 app[web.1]: at Object.Module._extensions..js (module.js:663:10)
2018-10-07T15:48:02.936995+00:00 app[web.1]: at Module.load (module.js:565:32)
2018-10-07T15:48:02.936996+00:00 app[web.1]: at tryModuleLoad (module.js:505:12)
2018-10-07T15:48:02.936998+00:00 app[web.1]: at Function.Module._load (module.js:497:3)
2018-10-07T15:48:02.936999+00:00 app[web.1]: at Function.Module.runMain (module.js:693:10)
2018-10-07T15:48:02.937001+00:00 app[web.1]: at startup (bootstrap_node.js:191:16)
2018-10-07T15:48:02.937003+00:00 app[web.1]: at bootstrap_node.js:612:3
2018-10-07T15:48:03.081497+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2018-10-07T15:48:03.082095+00:00 app[web.1]: npm ERR! errno 1
2018-10-07T15:48:03.083978+00:00 app[web.1]: npm ERR! server#1.0.0 start: `node index.js`
2018-10-07T15:48:03.088003+00:00 app[web.1]: npm ERR! Exit status 1
2018-10-07T15:48:03.088362+00:00 app[web.1]: npm ERR!
2018-10-07T15:48:03.088616+00:00 app[web.1]: npm ERR! Failed at the server#1.0.0 start script.
2018-10-07T15:48:03.088965+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
I'm not sure what else to do. Why can I run node index.js but not the start script that does the same thing?
I had to change process.env.NODE to process.env.PORT...
I know, I know...
I have a simple REST API deployed in Heroku. It uses MongoDB as the document storage service for the endpoints. It fails to run properly ever since I ran npm install to add another module for a different set of features. It doesn't matter what I do at that point, until I replace the node_modules folder (locally) with an older version before the last time I ran npm install, and re-deploy.
2018-08-03T16:12:14.920647+00:00 heroku[web.1]: Starting process with command npm start
2018-08-03T16:12:18.405746+00:00 app[web.1]:
2018-08-03T16:12:18.405762+00:00 app[web.1]: > todolistapi#1.0.0 start /app
2018-08-03T16:12:18.405764+00:00 app[web.1]: > node server.js
2018-08-03T16:12:18.405766+00:00 app[web.1]:
2018-08-03T16:12:18.593093+00:00 app[web.1]: /app
2018-08-03T16:12:18.594629+00:00 app[web.1]: /app
2018-08-03T16:12:19.115500+00:00 app[web.1]: module.js:549
2018-08-03T16:12:19.115542+00:00 app[web.1]: throw err;
2018-08-03T16:12:19.115544+00:00 app[web.1]: ^
2018-08-03T16:12:19.115545+00:00 app[web.1]:
2018-08-03T16:12:19.115547+00:00 app[web.1]: Error: Cannot find module './decimal128'
2018-08-03T16:12:19.115550+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:547:15)
2018-08-03T16:12:19.115551+00:00 app[web.1]: at Function.Module._load (module.js:474:25)
2018-08-03T16:12:19.115553+00:00 app[web.1]: at Module.require (module.js:596:17)
2018-08-03T16:12:19.115554+00:00 app[web.1]: at require (internal/module.js:11:18)
2018-08-03T16:12:19.115556+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/mongoose/lib/drivers/node-mongodb-native/index.js:6:22)
2018-08-03T16:12:19.115558+00:00 app[web.1]: at Module._compile (module.js:652:30)
2018-08-03T16:12:19.115559+00:00 app[web.1]: at Object.Module._extensions..js (module.js:663:10)
2018-08-03T16:12:19.115561+00:00 app[web.1]: at Module.load (module.js:565:32)
2018-08-03T16:12:19.115562+00:00 app[web.1]: at tryModuleLoad (module.js:505:12)
2018-08-03T16:12:19.115564+00:00 app[web.1]: at Function.Module._load (module.js:497:3)
I read at least 10 other articles, and tried downgrading, reinstalling MongoDB with no success.
Issue: my local node_modules folders was being included in my push to Heroku. Once removed, the application runs fine on Heroku:
git rm -r --cached node_modules
git commit -m 'Remove the now ignored directory node_modules'
git push origin master
I'm getting the error:
2012-01-28T00:13:51+00:00 heroku[web.1]: Starting process with command `node server.js`
2012-01-28T00:13:51+00:00 app[web.1]:
2012-01-28T00:13:51+00:00 app[web.1]: node.js:134
2012-01-28T00:13:51+00:00 app[web.1]: throw e; // process.nextTick error, or 'error' event on first tick
2012-01-28T00:13:51+00:00 app[web.1]: ^
2012-01-28T00:13:51+00:00 app[web.1]: at Array.<anonymous> (module.js:423:10)
2012-01-28T00:13:51+00:00 app[web.1]: Error: Cannot find module '/app/server.js'
2012-01-28T00:13:51+00:00 app[web.1]: at Function._resolveFilename (module.js:320:11)
2012-01-28T00:13:51+00:00 app[web.1]: at Function._load (module.js:266:25)
2012-01-28T00:13:51+00:00 app[web.1]: at EventEmitter._tickCallback (node.js:126:26)
My Node app server is in server.js at the root, I have no idea how to fix this.
I've done it from cloud9ide and it works fine, I did a deploy from there to heroku.
It looks like something is trying to require('server') somewhere in your app, which isn't necessary. The error is coming from module.js which deals with require-ing node modules. If you could provide your Procfile and maybe some source code it might be easier to pin down the problem, but based on first glance it looks like there's a relative path pointing to /app/server.js somewhere in your server code which shouldn't be doing so.