So I am trying to deploy a discord bot through heroku but am having issues with the deployment.. everything works fine when I run my bot locally but when trying to deploy to heroku I get this:
2020-03-21T18:08:07.914594+00:00 heroku[worker.1]: Starting process with command node index.js
2020-03-21T18:08:08.476878+00:00 heroku[worker.1]: State changed from starting to up
2020-03-21T18:08:10.286392+00:00 heroku[worker.1]: State changed from up to crashed
2020-03-21T18:08:10.215281+00:00 app[worker.1]: internal/modules/cjs/loader.js:796
2020-03-21T18:08:10.215306+00:00 app[worker.1]: throw err;
2020-03-21T18:08:10.215307+00:00 app[worker.1]: ^
2020-03-21T18:08:10.215307+00:00 app[worker.1]:
2020-03-21T18:08:10.215307+00:00 app[worker.1]: Error: Cannot find module 'enmap'
2020-03-21T18:08:10.215308+00:00 app[worker.1]: Require stack:
2020-03-21T18:08:10.215308+00:00 app[worker.1]: - /app/index.js
2020-03-21T18:08:10.215323+00:00 app[worker.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:793:17)
2020-03-21T18:08:10.215324+00:00 app[worker.1]: at Function.Module._load (internal/modules/cjs/loader.js:686:27)
2020-03-21T18:08:10.215329+00:00 app[worker.1]: at Module.require (internal/modules/cjs/loader.js:848:19)
2020-03-21T18:08:10.215330+00:00 app[worker.1]: at require (internal/modules/cjs/helpers.js:74:18)
2020-03-21T18:08:10.215330+00:00 app[worker.1]: at Object. (/app/index.js:4:15)
2020-03-21T18:08:10.215330+00:00 app[worker.1]: at Module._compile (internal/modules/cjs/loader.js:955:30)
2020-03-21T18:08:10.215331+00:00 app[worker.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
2020-03-21T18:08:10.215331+00:00 app[worker.1]: at Module.load (internal/modules/cjs/loader.js:811:32)
2020-03-21T18:08:10.215331+00:00 app[worker.1]: at Function.Module._load (internal/modules/cjs/loader.js:723:14)
2020-03-21T18:08:10.215331+00:00 app[worker.1]: at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10) {
2020-03-21T18:08:10.215337+00:00 app[worker.1]: code: 'MODULE_NOT_FOUND',
2020-03-21T18:08:10.215337+00:00 app[worker.1]: requireStack: [ '/app/index.js' ]
2020-03-21T18:08:10.215337+00:00 app[worker.1]: }
2020-03-21T18:08:10.270170+00:00 heroku[worker.1]: Process exited with status 1
I have followed steps found at https://devcenter.heroku.com/articles/troubleshooting-node-deploys#ensure-you-aren-t-relying-on-untracked-dependencies. but still getting error.. the app log is saying the app is deployed but the bot is not coming online. I don't know what to do at this point. Any help or point to any article would be greatly helpful.
my package.json is here >
{
"name": "botname",
"version": "1.0.0",
"description": "botname Discord Server Bot",
"main": "index.js",
"start": "node .",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Skemicle",
"license": "ISC",
"dependencies": {
"discord.js": "^11.5.1"
},
"engines": {
"node": "12.14.1",
"npm": "6.13.4"
}
}
"dependencies": {
"discord.js": "^11.5.1",
"enmap": "^5.2.4"
},
you have to add enmap to dependencies and if you are using other npm libraries you have to add that to dependencies also because heroku installs dependencies via npm install and that downloads packages listed in package.json -> dependencies.
Related
When I tried to deploy my app to heroku, I kept getting this error in the log
2022-05-20T14:49:35.602605+00:00 app[web.1]: > node server.js
2022-05-20T14:49:35.602605+00:00 app[web.1]:
2022-05-20T14:49:35.719423+00:00 app[web.1]: node:internal/modules/cjs/loader:936
2022-05-20T14:49:35.719424+00:00 app[web.1]: throw err;
2022-05-20T14:49:35.719425+00:00 app[web.1]: ^
2022-05-20T14:49:35.719428+00:00 app[web.1]:
2022-05-20T14:49:35.719428+00:00 app[web.1]: Error: Cannot find module 'csv-parse'
2022-05-20T14:49:35.719428+00:00 app[web.1]: Require stack:
2022-05-20T14:49:35.719429+00:00 app[web.1]: - /app/server.js
2022-05-20T14:49:35.719430+00:00 app[web.1]: at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
2022-05-20T14:49:35.719431+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:778:27)
2022-05-20T14:49:35.719431+00:00 app[web.1]: at Module.require (node:internal/modules/cjs/loader:1005:19)
2022-05-20T14:49:35.719431+00:00 app[web.1]: at require (node:internal/modules/cjs/helpers:102:18)
2022-05-20T14:49:35.719432+00:00 app[web.1]: at Object.<anonymous> (/app/server.js:6:15)
2022-05-20T14:49:35.719432+00:00 app[web.1]: at Module._compile (node:internal/modules/cjs/loader:1105:14)
2022-05-20T14:49:35.719432+00:00 app[web.1]: at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
2022-05-20T15:08:40.259973+00:00 app[web.1]: Error: Cannot find module 'express'
2022-05-20T15:08:40.259974+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:536:15)
2022-05-20T15:08:40.259974+00:00 app[web.1]: at Function.Module._load (module.js:466:25)
2022-05-20T15:08:40.259974+00:00 app[web.1]: at Module.require (module.js:579:17)
2022-05-20T15:08:40.259974+00:00 app[web.1]: at require (internal/module.js:11:18)
2022-05-20T15:08:40.259975+00:00 app[web.1]: at Object.<anonymous> (/app/server.js:5:17)
2022-05-20T15:08:40.259975+00:00 app[web.1]: at Module._compile (module.js:635:30)
2022-05-20T15:08:40.259975+00:00 app[web.1]: at Object.Module._extensions..js (module.js:646:10)
2022-05-20T15:08:40.259975+00:00 app[web.1]: at Module.load (module.js:554:32)
2022-05-20T15:08:40.259976+00:00 app[web.1]: at tryModuleLoad (module.js:497:12)
I am pretty sure the node.js application can successfully run locally and I have installed all the necessary packages in dependencies inside package.json. Not sure how to fix it....
Here is my package.json
{
"name": "Netflix User Study Framework",
"version": "1.0.0",
"description": "Encode username into prolific id",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js"
},
"engines": {
"node": "8.9.3"
},
"repository": {
"type": "git",
"url": "git+https://github.com/amyhua/basic-website-template-node.git"
},
"author": "YOUR NAME GOES HERE",
"bugs": {
"url": "https://github.com/amyhua/basic-website-template-node/issues"
},
"homepage": "https://github.com/amyhua/basic-website-template-node#readme",
"dependencies": {
"aws-sdk": "^2.1139.0",
"csv-parser": "^3.0.0",
"csv-stringify": "^6.0.5",
"express": "^4.14.0",
"generate-unique-id": "^2.0.1",
"http": "0.0.0",
"multer": "^1.4.4",
"nodemon": "^1.11.0",
"os": "^0.1.2"
}
}
Also, I set up a .env file with PORT # on 3000.
i am creating a discord bot and hosting it on heroku. i installed the moment.js library but it can't find it giving the following error
2022-03-27T12:41:48.954612+00:00 app[worker.1]: Error: Cannot find module 'moment'
2022-03-27T12:41:48.954612+00:00 app[worker.1]: Require stack:
2022-03-27T12:41:48.954612+00:00 app[worker.1]: - /app/bot.js
2022-03-27T12:41:48.954622+00:00 app[worker.1]: at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
2022-03-27T12:41:48.954625+00:00 app[worker.1]: at Function.Module._load (node:internal/modules/cjs/loader:778:27)
2022-03-27T12:41:48.954625+00:00 app[worker.1]: at Module.require (node:internal/modules/cjs/loader:1005:19)
2022-03-27T12:41:48.954626+00:00 app[worker.1]: at require (node:internal/modules/cjs/helpers:102:18)
2022-03-27T12:41:48.954626+00:00 app[worker.1]: at Object.<anonymous> (/app/bot.js:3:16)
2022-03-27T12:41:48.954626+00:00 app[worker.1]: at Module._compile (node:internal/modules/cjs/loader:1103:14)
2022-03-27T12:41:48.954626+00:00 app[worker.1]: at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
2022-03-27T12:41:48.954627+00:00 app[worker.1]: at Module.load (node:internal/modules/cjs/loader:981:32)
2022-03-27T12:41:48.954627+00:00 app[worker.1]: at Function.Module._load (node:internal/modules/cjs/loader:822:12)
2022-03-27T12:41:48.954627+00:00 app[worker.1]: at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12) {
2022-03-27T12:41:48.954628+00:00 app[worker.1]: code: 'MODULE_NOT_FOUND',
2022-03-27T12:41:48.954628+00:00 app[worker.1]: requireStack: [ '/app/bot.js' ]
2022-03-27T12:41:48.954628+00:00 app[worker.1]: }
my code
const moment = require('moment');
how should i do?
package.json:
{
"name": "freaksland-bot",
"version": "1.0.0",
"description": "",
"main": "bot.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"#discordjs/voice": "^0.8.0",
"moment.js": "^2.29.1",
"discord.js": "^13.6.0",
"init": "^0.1.2"
}
}
You are depending on moment.js, but the correct package is just moment.
Did you manually add that to your package.json? First, remove that line.
Then add the correct package:
If you are using Yarn, run yarn add moment
If you are using NPM, run npm install moment
This should install the dependency locally and also add it to your package.json and the relevant lock file. Commit the changes to those files and redeploy.
I was trying to deploy a practice project to Heroku and it gets deployed. However there is a application error, which is preventing the app to run on the server. I got some details about the errors, after running heroku logs.
2022-03-07T01:25:09.883329+00:00 app[web.1]: node:internal/modules/cjs/loader:936
2022-03-07T01:25:09.883379+00:00 app[web.1]: throw err;
2022-03-07T01:25:09.883379+00:00 app[web.1]: ^
2022-03-07T01:25:09.883379+00:00 app[web.1]:
2022-03-07T01:25:09.883380+00:00 app[web.1]: Error: Cannot find module './common'
2022-03-07T01:25:09.883380+00:00 app[web.1]: Require stack:
2022-03-07T01:25:09.883380+00:00 app[web.1]: - /app/node_modules/debug/src/node.js
2022-03-07T01:25:09.883381+00:00 app[web.1]: - /app/node_modules/debug/src/index.js
2022-03-07T01:25:09.883381+00:00 app[web.1]: - /app/node_modules/mquery/lib/mquery.js
2022-03-07T01:25:09.883382+00:00 app[web.1]: - /app/node_modules/mongoose/lib/promise_provider.js
2022-03-07T01:25:09.883382+00:00 app[web.1]: - /app/node_modules/mongoose/lib/helpers/promiseOrCallback.js
2022-03-07T01:25:09.883382+00:00 app[web.1]: - /app/node_modules/mongoose/lib/utils.js
2022-03-07T01:25:09.883382+00:00 app[web.1]: - /app/node_modules/mongoose/lib/statemachine.js
2022-03-07T01:25:09.883383+00:00 app[web.1]: - /app/node_modules/mongoose/lib/internal.js
2022-03-07T01:25:09.883383+00:00 app[web.1]: - /app/node_modules/mongoose/lib/document.js
2022-03-07T01:25:09.883383+00:00 app[web.1]: - /app/node_modules/mongoose/lib/index.js
2022-03-07T01:25:09.883383+00:00 app[web.1]: - /app/node_modules/mongoose/index.js
2022-03-07T01:25:09.883386+00:00 app[web.1]: - /app/db/connect.js
2022-03-07T01:25:09.883386+00:00 app[web.1]: - /app/app.js
2022-03-07T01:25:09.883387+00:00 app[web.1]: at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
2022-03-07T01:25:09.883387+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:778:27)
2022-03-07T01:25:09.883388+00:00 app[web.1]: at Module.require (node:internal/modules/cjs/loader:1005:19)
2022-03-07T01:25:09.883388+00:00 app[web.1]: at require (node:internal/modules/cjs/helpers:102:18)
2022-03-07T01:25:09.883388+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/debug/src/node.js:240:18)
2022-03-07T01:25:09.883389+00:00 app[web.1]: at Module._compile (node:internal/modules/cjs/loader:1103:14)
2022-03-07T01:25:09.883389+00:00 app[web.1]: at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
2022-03-07T01:25:09.883389+00:00 app[web.1]: at Module.load (node:internal/modules/cjs/loader:981:32)
2022-03-07T01:25:09.883390+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:822:12)
2022-03-07T01:25:09.883390+00:00 app[web.1]: at Module.require (node:internal/modules/cjs/loader:1005:19) {
2022-03-07T01:25:09.883390+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2022-03-07T01:25:09.883390+00:00 app[web.1]: requireStack: [
2022-03-07T01:25:09.883391+00:00 app[web.1]: '/app/node_modules/debug/src/node.js',
2022-03-07T01:25:09.883391+00:00 app[web.1]: '/app/node_modules/debug/src/index.js',
2022-03-07T01:25:09.883391+00:00 app[web.1]: '/app/node_modules/mquery/lib/mquery.js',
2022-03-07T01:25:09.883392+00:00 app[web.1]: '/app/node_modules/mongoose/lib/promise_provider.js',
2022-03-07T01:25:09.883392+00:00 app[web.1]: '/app/node_modules/mongoose/lib/helpers/promiseOrCallback.js',
2022-03-07T01:25:09.883393+00:00 app[web.1]: '/app/node_modules/mongoose/lib/utils.js',
2022-03-07T01:25:09.883393+00:00 app[web.1]: '/app/node_modules/mongoose/lib/statemachine.js',
2022-03-07T01:25:09.883393+00:00 app[web.1]: '/app/node_modules/mongoose/lib/internal.js',
2022-03-07T01:25:09.883393+00:00 app[web.1]: '/app/node_modules/mongoose/lib/document.js',
2022-03-07T01:25:09.883394+00:00 app[web.1]: '/app/node_modules/mongoose/lib/index.js',
2022-03-07T01:25:09.883394+00:00 app[web.1]: '/app/node_modules/mongoose/index.js',
2022-03-07T01:25:09.883394+00:00 app[web.1]: '/app/db/connect.js',
2022-03-07T01:25:09.883394+00:00 app[web.1]: '/app/app.js'
2022-03-07T01:25:09.883394+00:00 app[web.1]: ]
2022-03-07T01:25:09.883395+00:00 app[web.1]: }
2022-03-07T01:25:10.033008+00:00 heroku[web.1]: Process exited with status 1
2022-03-07T01:25:10.264584+00:00 heroku[web.1]: State changed from starting to crashed
I have installed the common package separately using npm install common --save, but that did not solve the issue. Also deleted node_modules and reinstalled all the modules. However nothing seems to work. I've scoured the internet for an answer to this, and haven't found anything yet that works.
My package.json looks like this,
{
"name": "starter-again",
"version": "1.0.0",
"main": "app.js",
"scripts": {
"start": "node app.js"
},
"author": "",
"license": "ISC",
"devDependencies": {
"dotenv": "^16.0.0",
"nodemon": "^2.0.15"
},
"dependencies": {
"common": "^0.2.5",
"debug": "^4.3.3",
"express": "^4.17.3",
"mongoose": "^6.2.4"
},
"engines": {
"node": "16.14.0"
},
}
Any suggestion on how to solve this error?
I solved this by not having node_modules in my .gitignore folder which was there originally.
ok so here is what i got on cli
anyone how to fix this
i have tried
npm cache clean but its not working
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module 'express'
Require stack:
- C:\Users\iftkh\Backend\index.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (C:\Users\iftkh\Backend\index.js:1:17)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [ 'C:\\Users\\iftkh\\Backend\\index.js' ]
I think you should install express correctly, or maybe didn't required it
could someone solve the problem? Have similar one and can't understand it why!
everything is installed.
{
"name": "server",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.18.1",
"mysql": "^2.18.1"
}
}
I am failing to start my node-based application on Openshift. The application starts OK locally but node's automatic deployment (on push to the remote master repo) hits a cyclic problem with the log;
DEBUG: Running node-supervisor with
DEBUG: program './app/server.js'
DEBUG: --watch '/var/lib/openshift/53dab282e0b8cdd367000131/app-root/data/.nodewatch'
DEBUG: --ignore 'undefined'
DEBUG: --extensions 'node|js|coffee'
DEBUG: --exec 'node'
DEBUG: Starting child process with 'node ./app/server.js'
DEBUG: Watching directory '/var/lib/openshift/53dab282e0b8cdd367000131/app-root/data/.nodewatch' for changes.
module.js:340
throw err;
^
Error: Cannot find module 'underscore.string'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/var/lib/openshift/53dab282e0b8cdd367000131/app-root/runtime/repo/node_modules/sequelize/lib/utils.js:5:26)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
DEBUG: Program node ./app/server.js exited with code 8
DEBUG: Starting child process with 'node ./app/server.js'
module.js:340
throw err;
^
Error: Cannot find module 'underscore.string'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/var/lib/openshift/53dab282e0b8cdd367000131/app-root/runtime/repo/node_modules/sequelize/lib/utils.js:5:26)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
DEBUG: Program node ./app/server.js exited with code 8
...this loop continues indefinitely, the app reports "Started" but clearly it's failed to initialize sequelize.js.
I'm a bit lost and loosing the faith in Openshift hosting at this point. I think this might be the last straw. Any advice?
Here is my app's package.json;
{
"name": "OceanLife-API",
"version": "1.1.0",
"description": "OceanLife API",
"keywords": [
"OceanLife",
"API",
"tide",
"swell",
"weather"
],
"author": {
"name": "David Branton",
"email": "oceanlife.development#gmail.com",
"url": "http://oceanlifeapi-brantapps.rhcloud.com/"
},
"homepage": "http://oceanlifeapi-brantapps.rhcloud.com/",
"repository": {
"type": "git",
"url": "https://github.com/openshift/origin-server"
},
"engines": {
"node": ">= 0.10.25",
"npm": ">= 1.3.24"
},
"dependencies": {
"express": "~3.4.8",
"sleep": "~1.1.8",
"aglio": "~1.14.0",
"sequelize": "~1.7.10",
"lodash": "~2.4.1",
"mysql": "~2.4.3",
"cheerio": "~0.17.0",
"moment": "~2.9.0",
"moment-timezone": "~0.2.5",
"tzwhere": "~1.0.0",
"line-reader": "~0.2.4"
},
"scripts": {
"lint": "./node_modules/.bin/jshint app/**/*.js",
"pretest": "npm run-script lint",
"test": "./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha -- --recursive -R spec"
},
"devDependencies": {
"istanbul": "~0.3.5",
"rewire": "~2.1.3",
"sinon": "~1.12.2",
"mocha": "~2.1.0",
"nock": "~0.57.0",
"dredd": "~0.3.14",
"jshint": "~2.5.11"
},
"bundleDependencies": [],
"private": true,
"main": "./app/server.js"
}
I've come back to this recently and have managed to get it working by using the community built Node v0.12 cartridge. If you are having similar issues I'd recommend ditching the "official" Node v0.1 app cartridge and trying again.
Sweet - free hosting of my node app! :D