gpt4 book ai didi

node.js - 在 Heroku 上运行时找不到模块 './mergeConfig'

转载 作者:太空宇宙 更新时间:2023-11-03 23:56:29 24 4
gpt4 key购买 nike

我有一个 Node 应用程序,通过 node my_application.js 在我的计算机上执行时运行良好。

但是,如果将其推送到heroku并通过heroku run node my_application.js或使用调度程序执行它,我得到的是这个错误:

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)

我在本地和 Heroku 上运行 Node v10.16.0 和 npm v6.9.0,所以我真的不知道是什么导致了这个问题,谷歌搜索也没有任何帮助。

关于这个 mergeConfig 模块的任何想法似乎在我的 Heroku 环境中缺失,但在我的本地环境中却没有?

编辑:这是我的 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"
}
}

最佳答案

尝试在 package.json 的依赖项中显式添加缺少的模块:

 "dependencies": {
...
"merge-config" :"2.0.0"
...
}

我认为它适用于您的本地环境,因为您已在全局安装了该模块。

关于node.js - 在 Heroku 上运行时找不到模块 './mergeConfig',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56878351/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com