Cannot find module './mergeConfig' when running on Heroku - node.js

I have a node application that runs fine when executed on my machine via node my_application.js.
However, if push it to heroku and execute it via heroku run node my_application.js or with the scheduler what I get is this error:
internal/modules/cjs/loader.js:638
throw err;
^
Error: Cannot find module './mergeConfig'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:690:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/app/node_modules/axios/lib/core/Axios.js:7:19)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787: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)
I'm running node v10.16.0 and npm v6.9.0 both locally and on Heroku, so I really don't know what may be causing this issue, and googling for it didn't help in any way.
Any ideas about this mergeConfig module that seems to be missing from my heroku environment but not from my local environment?
Edit: this is my package.json:
{
"name": "[REDACTED]",
"version": "1.0.0",
"description": "[REDACTED]",
"author": "",
"license": "ISC",
"dependencies": {
"axios": "^0.19.0",
"bluebird": "^3.5.3",
"body-parser": "^1.18.3",
"dateformat": "^3.0.3",
"express": "^4.16.4",
"form-data": "^2.3.3",
"http-to-curl": "^1.4.2",
"jest": "^24.8.0",
"qs": "^6.6.0",
"querystring": "^0.2.0",
"redis": "^2.8.0",
"simple-oauth2": "^2.2.1"
}
}

Try to add explicitly the missing module in the dependencies in package.json:
"dependencies": {
...
"merge-config" :"2.0.0"
...
}
I think it works on your local environment because you have the module installed globally.

I had the same problem.
'./mergeConfig' is a file inside de axios module.
Path: node_modules/axios/core/mergeConfig.js
For some reason heroku had a problem with this file.
I solved it by replacing axios with request.

This fixed the problem for me NODE_OPTIONS=--max_old_space_size=4096
src: https://github.com/axios/axios/issues/1767#issuecomment-416924946

Related

Running Electron on windows: Error: A dynamic link library (DLL) initialization routine failed

I am trying to the run an electron app on windows that uses aws-crt. Everything works fine on MacOS.
But in windows, I get this error:
App threw an error during load
Error: A dynamic link library (DLL) initialization routine failed.
\\?\C:\Code\mir-kiosk-electron\electron-kiosk\node_modules\aws-crt\dist\bin\win32-x64\aws-crt-nodejs.node
at process.func [as dlopen] (electron/js2c/asar_bundle.js:5:1846)
at Object.Module._extensions..node (internal/modules/cjs/loader.js:1138:18)
at Object.func [as .node] (electron/js2c/asar_bundle.js:5:1846)
at Module.load (internal/modules/cjs/loader.js:935:32)
at Module._load (internal/modules/cjs/loader.js:776:14)
at Function.f._load (electron/js2c/asar_bundle.js:5:12684)
at Module.require (internal/modules/cjs/loader.js:959:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (C:\Code\mir-kiosk-electron\electron-kiosk\.webpack\main\index.js:8461:19)
at Object../node_modules/aws-crt/dist/native/binding.js (C:\Code\mir-kiosk-electron\electron-kiosk\.webpack\main\index.js:8470:30)
webpack built f8189be91ec9475472dc in 1864ms
What should I do?
I found a similar issue in https://github.com/electron/electron/issues/11853.
It says I need to rebuild the node module.
I have already done
.\node_modules\.bin\electron-rebuild.cmd
The error is still there.
Here is my package.json
"dependencies": {
"aws-crt": "^1.7.1",
"aws-iot-device-sdk-v2": "^1.5.1",
"axios": "^0.21.1",
"electron-squirrel-startup": "^1.0.0",
"jimp": "^0.16.1",
"pixelmatch": "^5.2.1",
"pngjs": "^6.0.0",
"react": "^17.0.2",
"react-dom": "^17.0.2"
}
My gut feeling is I need to rebuild aws-crt for electron. But how do I do it?

Error : Cannot find Module 'fabric-client' in fabric 1.2

Even after trying "npm update" command, still i am facing fabric-client error. The error details given below
Fabric version - 1.2 |
OS - Amazon Linux2 |
command - npm i
[root#ip-172-31-61-27 controller]# node app.js
module.js:538
throw err;
^
Error: Cannot find module 'fabric-client'
at Function.Module._resolveFilename (module.js:536:15)
at Function.Module._load (module.js:466:25)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/home/ec2-user/AWSNodeApp/controller/app.js:27:11)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
Below is the content of package.json
{
"name": "awsnodeapp",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"aws-sdk": "^2.538.0",
"body-parser": "^1.17.1",
"cors": "^2.8.3",
"express": "^4.15.2",
"express-session": "^1.15.2",
"fabric-ca-client": "1.3.0",
"fabric-client": "1.3.0",
"fs-extra": "^2.0.0",
"log4js": "^3.0.6",
"uuid": "^3.3.2",
"ws": "^6.1.0"
}
}
That looks like the kind of error you get if you haven't actually downloaded your project dependencies with npm install prior to running your application. Or have not included a dependency required by your code in your project's package.json. Or possibly the npm install failed to download the dependencies due to connectivity issues accessing the npm registry. Either way, if you don't have a node_modules/fabric-client directory within your project directory, you haven't downloaded your required dependency.
The fabric-client#1.2 package definitely exists: https://www.npmjs.com/package/fabric-client/v/1.2.2
Note that this version of Hyperledger Fabric is obsolete. As of today (August 2020), you really should be using v1.4 or (ideally) v2.2. Note that the Node SDK has changed with the v2.2 release and, although the v1.4 fabric-client package will still work with a v2.2 Fabric, it is recommended to use fabric-network#2.2: https://hyperledger.github.io/fabric-sdk-node/release-2.2/tutorial-migration.html
fabric client module is not installed in your project. try this command to install fabric-client module
npm i fabric-client

error deploying node.js app to heroku

I'm trying to deploy my node.js app to heroku.
I'm getting this error on git push heroku master:
> on-headers#1.0.1 test /tmp/build_4d6fe429e576b4e42425b713c87264e9/node_modules/response-time/node_modules/on-headers
> mocha --reporter spec --bail --check-leaks test/
/tmp/build_4d6fe429e576b4e42425b713c87264e9/node_modules/mocha/lib/utils.js:626
throw new Error("cannot resolve path (or pattern) '" + path + "'");
^
Error: cannot resolve path (or pattern) 'test/'
at Object.lookupFiles (/tmp/build_4d6fe429e576b4e42425b713c87264e9/node_modules/mocha/lib/utils.js:626:15)
at /tmp/build_4d6fe429e576b4e42425b713c87264e9/node_modules/mocha/bin/_mocha:316:30
at Array.forEach (native)
at Object.<anonymous> (/tmp/build_4d6fe429e576b4e42425b713c87264e9/node_modules/mocha/bin/_mocha:315:6)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Function.Module.runMain (module.js:467:10)
at startup (node.js:136:18)
at node.js:963:3
> node-statsd#0.1.1 test /tmp/build_4d6fe429e576b4e42425b713c87264e9/node_modules/soluto-monitor/node_modules/node-statsd
> mocha -R spec
/tmp/build_4d6fe429e576b4e42425b713c87264e9/node_modules/mocha/lib/utils.js:626
throw new Error("cannot resolve path (or pattern) '" + path + "'");
^
Error: cannot resolve path (or pattern) 'test'
at Object.lookupFiles (/tmp/build_4d6fe429e576b4e42425b713c87264e9/node_modules/mocha/lib/utils.js:626:15)
at /tmp/build_4d6fe429e576b4e42425b713c87264e9/node_modules/mocha/bin/_mocha:316:30
at Array.forEach (native)
at Object.<anonymous> (/tmp/build_4d6fe429e576b4e42425b713c87264e9/node_modules/mocha/bin/_mocha:315:6)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Function.Module.runMain (module.js:467:10)
at startup (node.js:136:18)
at node.js:963:3
...
..and on and on with the error Error: cannot resolve path (or pattern) 'test/' for each node_modules subdirectory.
my package.json looks like more or less like this:
{
"name": "my-module",
"version": "0.1.0",
"description": "My Module",
"dependencies": {
"azure-storage": "0.6.0",
"bluebird": "3.0.6",
"body-parser": "1.14.1",
"cors": "2.7.1",
"dotenv": "^1.2.0",
"express": "3.3.3",
"moment": "2.10.6",
"request-promise": "1.0.2",
"rx": "4.0.7",
"shisell": "0.0.2",
"striptags": "2.0.4",
"winston": "2.1.1"
},
"devDependencies": {
"chai": "^3.4.1",
"chai-as-promised": "^5.1.0",
"mocha": "^2.3.4",
"mock-require": "^1.2.1",
"sinon": "^1.17.2",
"sinon-chai": "^2.8.0",
"supertest": "^1.1.0"
},
"main": "server.js",
"engines": {
"node": "4.2.3"
},
"scripts": {
"test": "mocha"
}
}
it seems like mocha is trying to run from within node_modules, inside each dependency. i managed to reproduce the error locally by running mocha from within one of the node_modules directories.
I tried removing test script from my package.json and I still get the same error.
I'm new to heroku deployments. As far as I understood once I git push to heroku then heroku runs npm install and if there is a test script it will run. But I don't understand what causes it to try and run mocha within subdirectories of node_modules (and why that would happen even if I don't specify a test script inside my package.json).
Any ideas?
p.s. this doesn't happen when I run locally on my machine.
Turns out I had this environment variable set: NPM_CONFIG_NPAT=true on heroku and it causes npm to run tests on all the installations, as described here:
https://docs.npmjs.com/misc/config#npat

ORMError NO_SUPPORT: Connection protocol not supported - have you installed the database driver for postgres?

I'm trying to deploy a nodejs application on ubuntu 13.10. I have tested it on my local mac( working good).
But when I try to run it on my ubuntu server, i got this:
[ORMError NO_SUPPORT: Connection protocol not supported - have you installed the database driver for postgres?]
at Object.exports.connect (/home/ubuntu/node_modules/orm/lib/ORM.js:138:21)
at Object.module.exports (/home/ubuntu/node_modules/orm/lib/Express.js:12:6)
at Object.exports.express (/home/ubuntu/node_modules/orm/lib/ORM.js:39:30)
at Object.<anonymous> (/home/ubuntu/www/sher/nodejs/app.js:30:13)
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)
at require (module.js:380:17)
error: Forever detected script exited with code: 8
FYI:
I installed npm install pg after i got this error, but didn't work.
I also instadded postgresql9.1 with sudo apt-get install build-essential postgresql-9.1 postgresql-server-dev-9.1 libxml2-dev libproj-dev libjson0-dev xsltproc docbook-xsl docbook-mathml.
Anyone can suggest any idea whats going on here?
Thank you!
{
"name": "nodejs",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node ./bin/www"
},
"dependencies": {
"express": "~4.2.0",
"static-favicon": "~1.0.0",
"morgan": "~1.0.0",
"cookie-parser": "~1.0.1",
"body-parser": "~1.0.0",
"debug": "~0.7.4",
"jade": "~1.3.0"
}
}
I just reinstalled all packages and modules again one by one. Seems fixed the problem.

Error: Cannot find module './proto' on Heroku

I can't seem to figure out why this works locally fine, but when I push it to Heroku it fails with the following error.
Error from Heroku
Starting process with command `node web.js`
module.js:337
throw new Error("Cannot find module '" + request + "'");
^
Error: Cannot find module './proto'
at Function._resolveFilename (module.js:337:11)
at Function._load (module.js:279:25)
at Module.require (module.js:359:17)
at require (module.js:375:17)
at Object.<anonymous> (/app/node_modules/express/node_modules/connect/lib/connect.js:14:13)
at Module._compile (module.js:446:26)
at Object..js (module.js:464:10)
at Module.load (module.js:353:31)
at Function._load (module.js:311:12)
at Module.require (module.js:359:17)
Process exited with status 1
State changed from starting to crashed
package.json
{
"name": "divtest",
"version": "0.0.2",
"dependencies": {
"underscore": "1.3.x",
"crypto": "0.0.x",
"knox": "0.3.x",
"mongoose": "~3.1.2",
"mime": "1.2.x",
"express": "3.0.x",
"request": "~2.9.203"
},
"engines": {
"node": "0.6.x",
"npm": "1.0.x"
}
}
./proto is a local module that connect is calling
I've blown away my ./node_modules folder and did a npm install --save and still get the same results.
I had this issue, and my problem was that I'm a git beginner and hadn't properly committed all of the files that were needed. It looks like there was a proto.js in connect somewhere.
I did a git add * (...) and pushed again and it all went nicely.
Another telling error, was that on push Heroku complained about unmet dependencies.

Resources