mdb with node js hosted on Heroku does not work - node.js

I used 'node-adodb' nodejs module with .mdb database. Here is my code.
const ADODB = require('node-adodb');
const connection = ADODB.open(`Provider=Microsoft.Jet.OLEDB.4.0;Data Source=${__dirname}/data/Database.mdb;`);
module.exports = { connection : connection };
This is worked on a local and throws the following error after hosted on Heroku.
throw new ERR_INVALID_ARG_TYPE(name, 'string', value);
2020-04-23T21:53:16.421683+00:00 app[web.1]: ^
2020-04-23T21:53:16.421683+00:00 app[web.1]:
2020-04-23T21:53:16.421684+00:00 app[web.1]: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
2020-04-23T21:53:16.421684+00:00 app[web.1]: at validateString (internal/validators.js:117:11)
2020-04-23T21:53:16.421685+00:00 app[web.1]: at Object.join (path.js:1039:7)
2020-04-23T21:53:16.421686+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/node-adodb/lib/engine.js:16:24)
2020-04-23T21:53:16.421686+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1156:30)
2020-04-23T21:53:16.421687+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
2020-04-23T21:53:16.421687+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:1000:32)
2020-04-23T21:53:16.421687+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:899:14)
2020-04-23T21:53:16.421688+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:1042:19)
2020-04-23T21:53:16.421688+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:77:18)
2020-04-23T21:53:16.421688+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/node-adodb/index.js:11:16) {
2020-04-23T21:53:16.421689+00:00 app[web.1]: code: 'ERR_INVALID_ARG_TYPE'
2020-04-23T21:53:16.421689+00:00 app[web.1]: }

Related

How to get rid of Heroku deploy error "Error: Cannot find module '../models/people' " for Node.js app?

I am trying to deploy a node.js app to heroku. But I am facing this ("Error: Cannot find module '../models/people' ) error. The app is working fine in localhost.
2022-11-01T17:45:47.000000+00:00 app[api]: Build succeeded
2022-11-01T17:45:47.265323+00:00 heroku[web.1]: State changed from crashed to starting
2022-11-01T17:45:50.307944+00:00 heroku[web.1]: Starting process with command `NODE_ENV=production node index.js`
2022-11-01T17:45:52.192313+00:00 app[web.1]: node:internal/modules/cjs/loader:936
2022-11-01T17:45:52.192350+00:00 app[web.1]: throw err;
2022-11-01T17:45:52.192350+00:00 app[web.1]: ^
2022-11-01T17:45:52.192351+00:00 app[web.1]:
2022-11-01T17:45:52.192351+00:00 app[web.1]: Error: Cannot find module '../models/people'
2022-11-01T17:45:52.192351+00:00 app[web.1]: Require stack:
2022-11-01T17:45:52.192351+00:00 app[web.1]: - /app/controller/login_controller.js
2022-11-01T17:45:52.192352+00:00 app[web.1]: - /app/router/login_router.js
2022-11-01T17:45:52.192352+00:00 app[web.1]: - /app/index.js
2022-11-01T17:45:52.192352+00:00 app[web.1]: at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
2022-11-01T17:45:52.192353+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:778:27)
2022-11-01T17:45:52.192353+00:00 app[web.1]: at Module.require (node:internal/modules/cjs/loader:1005:19)
2022-11-01T17:45:52.192353+00:00 app[web.1]: at require (node:internal/modules/cjs/helpers:102:18)
2022-11-01T17:45:52.192354+00:00 app[web.1]: at Object.<anonymous> (/app/controller/login_controller.js:2:14)
2022-11-01T17:45:52.192354+00:00 app[web.1]: at Module._compile (node:internal/modules/cjs/loader:1103:14)
2022-11-01T17:45:52.192354+00:00 app[web.1]: at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
2022-11-01T17:45:52.192355+00:00 app[web.1]: at Module.load (node:internal/modules/cjs/loader:981:32)
2022-11-01T17:45:52.192355+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:822:12)
2022-11-01T17:45:52.192355+00:00 app[web.1]: at Module.require (node:internal/modules/cjs/loader:1005:19) {
2022-11-01T17:45:52.192355+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2022-11-01T17:45:52.192356+00:00 app[web.1]: requireStack: [
2022-11-01T17:45:52.192356+00:00 app[web.1]: '/app/controller/login_controller.js',
2022-11-01T17:45:52.192356+00:00 app[web.1]: '/app/router/login_router.js',
2022-11-01T17:45:52.192357+00:00 app[web.1]: '/app/index.js'
2022-11-01T17:45:52.192357+00:00 app[web.1]: ]
2022-11-01T17:45:52.192357+00:00 app[web.1]: }
2022-11-01T17:45:52.307078+00:00 heroku[web.1]: Process exited with status 1
2022-11-01T17:45:52.382922+00:00 heroku[web.1]: State changed from starting to crashed

ERROR : hosting Ecommerce web application in Heroku

Well i build a web application for an online e-commerce store project as a sample project. It was doing prefectly well until i decided to put it online in heroku and now the project keeps giving an error in heroku:
Error:
2022-05-31T09:50:32.498928+00:00 app[web.1]: Error: Cannot find module './debug'
2022-05-31T09:50:32.498928+00:00 app[web.1]: Require stack:
2022-05-31T09:50:32.498928+00:00 app[web.1]: - /app/node_modules/mquery/node_modules/debug/src/node.js
2022-05-31T09:50:32.498929+00:00 app[web.1]: - /app/node_modules/mquery/node_modules/debug/src/index.js
2022-05-31T09:50:32.498929+00:00 app[web.1]: - /app/node_modules/mquery/lib/mquery.js
2022-05-31T09:50:32.498929+00:00 app[web.1]: - /app/node_modules/mongoose/lib/promise_provider.js
2022-05-31T09:50:32.498930+00:00 app[web.1]: - /app/node_modules/mongoose/lib/helpers/promiseOrCallback.js
2022-05-31T09:50:32.498930+00:00 app[web.1]: - /app/node_modules/mongoose/lib/utils.js
2022-05-31T09:50:32.498930+00:00 app[web.1]: - /app/node_modules/mongoose/lib/statemachine.js
2022-05-31T09:50:32.498930+00:00 app[web.1]: - /app/node_modules/mongoose/lib/internal.js
2022-05-31T09:50:32.498931+00:00 app[web.1]: - /app/node_modules/mongoose/lib/document.js
2022-05-31T09:50:32.498931+00:00 app[web.1]: - /app/node_modules/mongoose/lib/index.js
2022-05-31T09:50:32.498931+00:00 app[web.1]: - /app/node_modules/mongoose/index.js
2022-05-31T09:50:32.498932+00:00 app[web.1]: - /app/Backend/models/product.js
2022-05-31T09:50:32.498932+00:00 app[web.1]: - /app/Backend/controllers/products.js
2022-05-31T09:50:32.498932+00:00 app[web.1]: - /app/Backend/routes/products.js
2022-05-31T09:50:32.498933+00:00 app[web.1]: - /app/Backend/app.js
2022-05-31T09:50:32.498933+00:00 app[web.1]: - /app/Backend/server.js
2022-05-31T09:50:32.498933+00:00 app[web.1]: at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
2022-05-31T09:50:32.498934+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:778:27)
2022-05-31T09:50:32.498934+00:00 app[web.1]: at Module.require (node:internal/modules/cjs/loader:1005:19)
2022-05-31T09:50:32.498935+00:00 app[web.1]: at require (node:internal/modules/cjs/helpers:102:18)
2022-05-31T09:50:32.498935+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/mquery/node_modules/debug/src/node.js:14:28)
2022-05-31T09:50:32.498935+00:00 app[web.1]: at Module._compile (node:internal/modules/cjs/loader:1105:14)
2022-05-31T09:50:32.498935+00:00 app[web.1]: at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
2022-05-31T09:50:32.498936+00:00 app[web.1]: at Module.load (node:internal/modules/cjs/loader:981:32)
2022-05-31T09:50:32.498936+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:822:12)
2022-05-31T09:50:32.498937+00:00 app[web.1]: at Module.require (node:internal/modules/cjs/loader:1005:19) {
2022-05-31T09:50:32.498937+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2022-05-31T09:50:32.498937+00:00 app[web.1]: requireStack: [
2022-05-31T09:50:32.498937+00:00 app[web.1]: '/app/node_modules/mquery/node_modules/debug/src/node.js',
2022-05-31T09:50:32.498937+00:00 app[web.1]: '/app/node_modules/mquery/node_modules/debug/src/index.js',
2022-05-31T09:50:32.498938+00:00 app[web.1]: '/app/node_modules/mquery/lib/mquery.js',
2022-05-31T09:50:32.498938+00:00 app[web.1]: '/app/node_modules/mongoose/lib/promise_provider.js',
2022-05-31T09:50:32.498938+00:00 app[web.1]: '/app/node_modules/mongoose/lib/helpers/promiseOrCallback.js',
2022-05-31T09:50:32.498938+00:00 app[web.1]: '/app/node_modules/mongoose/lib/utils.js',
2022-05-31T09:50:32.498939+00:00 app[web.1]: '/app/node_modules/mongoose/lib/statemachine.js',
2022-05-31T09:50:32.498939+00:00 app[web.1]: '/app/node_modules/mongoose/lib/internal.js',
2022-05-31T09:50:32.498939+00:00 app[web.1]: '/app/node_modules/mongoose/lib/document.js',
2022-05-31T09:50:32.498939+00:00 app[web.1]: '/app/node_modules/mongoose/lib/index.js',
2022-05-31T09:50:32.498940+00:00 app[web.1]: '/app/node_modules/mongoose/index.js',
2022-05-31T09:50:32.498940+00:00 app[web.1]: '/app/Backend/models/product.js',
2022-05-31T09:50:32.498940+00:00 app[web.1]: '/app/Backend/controllers/products.js',
2022-05-31T09:50:32.498940+00:00 app[web.1]: '/app/Backend/routes/products.js',
2022-05-31T09:50:32.498941+00:00 app[web.1]: '/app/Backend/app.js',
2022-05-31T09:50:32.498941+00:00 app[web.1]: '/app/Backend/server.js'
I'm worried to of what have happened this is the first time im learning this . Thanks in advance.
Git: GIT

Cannot deploy an app on Heroku

I am trying to deploy an application to Heroku, but after deployment in the logs I get the following error:
2017-08-09T09:32:39.071603+00:00 app[web.1]:
2017-08-09T09:32:39.876049+00:00 app[web.1]: /app/main.js:38
2017-08-09T09:32:39.876059+00:00 app[web.1]: app.set('port', (process.env.PORT || 5000));
2017-08-09T09:32:39.876060+00:00 app[web.1]: ^
2017-08-09T09:32:39.876060+00:00 app[web.1]:
2017-08-09T09:32:39.876063+00:00 app[web.1]: TypeError: Cannot read property 'PORT' of undefined
2017-08-09T09:32:39.876063+00:00 app[web.1]: at Object.<anonymous> (/app/main.js:38:29)
2017-08-09T09:32:39.876064+00:00 app[web.1]: at Module._compile (module.js:570:32)
2017-08-09T09:32:39.876065+00:00 app[web.1]: at Object.Module._extensions..js (module.js:579:10)
2017-08-09T09:32:39.876065+00:00 app[web.1]: at Module.load (module.js:487:32)
2017-08-09T09:32:39.876068+00:00 app[web.1]: at tryModuleLoad (module.js:446:12)
2017-08-09T09:32:39.876069+00:00 app[web.1]: at Function.Module._load (module.js:438:3)
2017-08-09T09:32:39.876069+00:00 app[web.1]: at Module.runMain (module.js:604:10)
2017-08-09T09:32:39.876070+00:00 app[web.1]: at run (bootstrap_node.js:389:7)
2017-08-09T09:32:39.876070+00:00 app[web.1]: at startup (bootstrap_node.js:149:9)
2017-08-09T09:32:39.876071+00:00 app[web.1]: at bootstrap_node.js:504:3
I get the same error when I try to run the application locally
11:26:03 web.1 | var port = process.env.PORT || 5000;
11:26:03 web.1 | ^
11:26:03 web.1 | TypeError: Cannot read property 'PORT' of undefined
Does someone know what am I doing wrong?

NodeJs MongoDB and Heroku

While deploying a Node application to Heroku I'm receiving the following error message. Any ideas what might cause it?
2016-09-19T09:44:06.497018+00:00 app[web.1]: "stack": [
2016-09-19T09:44:06.497020+00:00 app[web.1]: "TypeError: options.mongooseConnection.once is not a function",
2016-09-19T09:44:06.497021+00:00 app[web.1]: " at MongoStore (/app/node_modules/connect-mongo/src/index.js:91:48)",
2016-09-19T09:44:06.497021+00:00 app[web.1]: " at Object. (/app/app/session/index.js:14:17)",
2016-09-19T09:44:06.497022+00:00 app[web.1]: " at Module._compile (module.js:413:34)",
2016-09-19T09:44:06.497022+00:00 app[web.1]: " at Object.Module._extensions..js (module.js:422:10)",
2016-09-19T09:44:06.497023+00:00 app[web.1]: " at Module.load (module.js:357:32)",
2016-09-19T09:44:06.497023+00:00 app[web.1]: " at Function.Module._load (module.js:314:12)",
2016-09-19T09:44:06.497024+00:00 app[web.1]: " at Module.require (module.js:367:17)",
2016-09-19T09:44:06.497024+00:00 app[web.1]: " at require (internal/module.js:20:19)",
2016-09-19T09:44:06.497025+00:00 app[web.1]: " at Object. (/app/app/index.js:16:15)",
2016-09-19T09:44:06.497025+00:00 app[web.1]: " at Module._compile (module.js:413:34)",
2016-09-19T09:44:06.497026+00:00 app[web.1]: " at Object.Module._extensions..js (module.js:422:10)",
2016-09-19T09:44:06.497027+00:00 app[web.1]: " at Module.load (module.js:357:32)",
2016-09-19T09:44:06.497027+00:00 app[web.1]: " at Function.Module._load (module.js:314:12)",
2016-09-19T09:44:06.497028+00:00 app[web.1]: " at Module.require (module.js:367:17)",
2016-09-19T09:44:06.497028+00:00 app[web.1]: " at require (internal/module.js:20:19)",
2016-09-19T09:44:06.497029+00:00 app[web.1]: " at Object. (/app/server.js:4:17)",
2016-09-19T09:44:06.497029+00:00 app[web.1]: " at Module._compile (module.js:413:34)",
2016-09-19T09:44:06.497030+00:00 app[web.1]: " at Object.Module._extensions..js (module.js:422:10)",
2016-09-19T09:44:06.497030+00:00 app[web.1]: " at Module.load (module.js:357:32)",
2016-09-19T09:44:06.497031+00:00 app[web.1]: " at Function.Module._load (module.js:314:12)",
2016-09-19T09:44:06.497032+00:00 app[web.1]: " at Function.Module.runMain (module.js:447:10)",
2016-09-19T09:44:06.497032+00:00 app[web.1]: " at startup (node.js:148:18)"
2016-09-19T09:44:06.497033+00:00 app[web.1]: ],
2016-09-19T09:44:06.497033+00:00 app[web.1]: "level": "error",
2016-09-19T09:44:06.497034+00:00 app[web.1]: "message": "uncaughtException: options.mongooseConnection.once is not a function"
2016-09-19T09:44:06.497035+00:00 app[web.1]: }
I think you are creating mongoose connection with connect not with createConnection method that's why you are getting this error.
.createConnection() returns a Connection instance.
.connect() returns the global mongoose instance.
Then if you want to use once method then you have to use createConnection method instead of connect method
var db = mongoose.createConnection('MongoDB URL');
db.once('open', function() { ... });

Syntax error on express app.use

I have used this code with my node.js application with express but when uploading to Heroku I get an error when running.
2016-09-28T11:01:40.502448+00:00 app[web.1]: /app/routes/index.js:146
2016-09-28T11:01:40.502467+00:00 app[web.1]: app.use(({method, url}, rsp, next) => {
2016-09-28T11:01:40.502468+00:00 app[web.1]: ^
2016-09-28T11:01:40.502468+00:00 app[web.1]:
2016-09-28T11:01:40.502469+00:00 app[web.1]: SyntaxError: Unexpected token {
2016-09-28T11:01:40.502469+00:00 app[web.1]: at exports.runInThisContext (vm.js:53:16)
2016-09-28T11:01:40.502470+00:00 app[web.1]: at Module._compile (module.js:387:25)
2016-09-28T11:01:40.502471+00:00 app[web.1]: at Object.Module._extensions..js (module.js:422:10)
2016-09-28T11:01:40.502471+00:00 app[web.1]: at Module.load (module.js:357:32)
2016-09-28T11:01:40.502472+00:00 app[web.1]: at Function.Module._load (module.js:314:12)
2016-09-28T11:01:40.502473+00:00 app[web.1]: at Module.require (module.js:367:17)
2016-09-28T11:01:40.502473+00:00 app[web.1]: at require (internal/module.js:20:19)
2016-09-28T11:01:40.502474+00:00 app[web.1]: at Object.<anonymous> (/app/app.js:8:14)
2016-09-28T11:01:40.502474+00:00 app[web.1]: at Module._compile (module.js:413:34)
2016-09-28T11:01:40.502475+00:00 app[web.1]: at Object.Module._extensions..js (module.js:422:10)
My code is
app.use(({method, url}, rsp, next) => {
rsp.on('finish', () => {
console.log(`${rsp.statusCode} ${method} ${url}`);
});
next();
});
Any help would be much appreciated
In your package.json, do you specify the node engine?
"engines": {
"node": "6.5.0"
}
I would have just added this as a comment, but I don't have enough rep.

Resources