简体   繁体   中英

Cannot find module './mergeConfig' when running on Heroku

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM