Nodejs 中 Heroku 构建步骤失败的可观察性模块在开发环境中工作

问题描述 投票:0回答:1

我最近尝试将可观察性模块添加到我的代码中,并且尝试了 honeycomb 和 new relic。

两者在我的开发环境中都工作得很好,并连接到各自的平台,当我使用 webpack 配置构建前端代码时,它也可以工作。

我认为这与 Heroku 构建步骤以及其末端的 web pack 有关,但我不确定如何解决它。

当我尝试在生产中部署时,我似乎从两个模块中得到了相同的错误(我每次都使用部署和双重检查来反转提交,所以我知道这很可能不是代码中的另一个因素+它在开发环境中工作有 0 个问题并且代码到目前为止在产品中没有任何问题):

Build
Running build
> [email protected] build
> webpack
assets by status 1.89 MiB [cached] 4 assets
orphan modules 364 KiB [orphan] 78 modules
runtime modules 792 bytes 4 modules
modules by path ./node_modules/@babel/polyfill/node_modules/core-js/modules/*.js 190 KiB 273 modules
modules by path ./node_modules/@babel/polyfill/node_modules/core-js/library/ 6.43 KiB 18 modules
modules by path ./node_modules/@babel/polyfill/node_modules/core-js/fn/ 1.29 KiB 11 modules
modules by path ./src/ 536 KiB
./src/pages/create.js 894 bytes [built] [code generated]
+ 3 modules
modules by path ./node_modules/@babel/polyfill/lib/*.js 1.22 KiB
./node_modules/@babel/polyfill/lib/index.js 686 bytes [built] [code generated]
./node_modules/@babel/polyfill/lib/noConflict.js 567 bytes [built] [code generated]
./node_modules/@babel/polyfill/node_modules/core-js/es6/index.js 5.78 KiB [built] [code generated]
./node_modules/@babel/polyfill/node_modules/core-js/web/index.js 157 bytes [built] [code generated]
./node_modules/regenerator-runtime/runtime.js 24.3 KiB [built] [code generated]
ERROR in ./node_modules/axios/lib/axios.js 18:0-46
Module not found: Error: Can't resolve './adapters/adapters.js' in '/tmp/build_64aff3bc/node_modules/axios/lib'
@ ./node_modules/axios/index.js 1:0-35 23:4-9 25:0-43:1
@ ./src/main.js 2:0-26 566:8-38 573:8-53 622:41-46 680:26-31 797:47-52 819:49-54 856:29-34 888:21-26 916:22-27 963:22-27 987:22-27 1028:22-27 1069:22-27 1105:22-27 1141:22-27 1165:22-27 1193:22-27 1216:22-27 1256:22-27 1293:22-27 1319:34-39 1333:25-30 1364:22-27 1390:31-36 1426:27-32 1455:24-29 1477:24-29 1496:24-29 1534:31-36 1548:25-30 1587:22-27 1607:22-27 1632:22-27 1660:22-27 1688:22-27 1716:22-27 1747:22-27 1781:22-27 1837:24-29 3262:22-27 3286:22-27 3315:22-27 3333:22-27 3350:22-27 3368:22-27 3386:22-27 3403:24-29 3420:24-29 3437:22-27
ERROR in ./node_modules/axios/lib/axios.js 19:0-57
Module not found: Error: Can't resolve './helpers/HttpStatusCode.js' in '/tmp/build_64aff3bc/node_modules/axios/lib'
@ ./node_modules/axios/index.js 1:0-35 23:4-9 25:0-43:1
@ ./src/main.js 2:0-26 566:8-38 573:8-53 622:41-46 680:26-31 797:47-52 819:49-54 856:29-34 888:21-26 916:22-27 963:22-27 987:22-27 1028:22-27 1069:22-27 1105:22-27 1141:22-27 1165:22-27 1193:22-27 1216:22-27 1256:22-27 1293:22-27 1319:34-39 1333:25-30 1364:22-27 1390:31-36 1426:27-32 1455:24-29 1477:24-29 1496:24-29 1534:31-36 1548:25-30 1587:22-27 1607:22-27 1632:22-27 1660:22-27 1688:22-27 1716:22-27 1747:22-27 1781:22-27 1837:24-29 3262:22-27 3286:22-27 3315:22-27 3333:22-27 3350:22-27 3368:22-27 3386:22-27 3403:24-29 3420:24-29 3437:22-27
ERROR in ./node_modules/axios/lib/core/dispatchRequest.js 8:0-47
Module not found: Error: Can't resolve '../adapters/adapters.js' in '/tmp/build_64aff3bc/node_modules/axios/lib/core'
@ ./node_modules/axios/lib/core/Axios.js 6:0-51 114:21-41 146:16-36
@ ./node_modules/axios/lib/axios.js 5:0-36 29:22-27 30:24-47 33:25-40 50:14-19
@ ./node_modules/axios/index.js 1:0-35 23:4-9 25:0-43:1
@ ./src/main.js 2:0-26 566:8-38 573:8-53 622:41-46 680:26-31 797:47-52 819:49-54 856:29-34 888:21-26 916:22-27 963:22-27 987:22-27 1028:22-27 1069:22-27 1105:22-27 1141:22-27 1165:22-27 1193:22-27 1216:22-27 1256:22-27 1293:22-27 1319:34-39 1333:25-30 1364:22-27 1390:31-36 1426:27-32 1455:24-29 1477:24-29 1496:24-29 1534:31-36 1548:25-30 1587:22-27 1607:22-27 1632:22-27 1660:22-27 1688:22-27 1716:22-27 1747:22-27 1781:22-27 1837:24-29 3262:22-27 3286:22-27 3315:22-27 3333:22-27 3350:22-27 3368:22-27 3386:22-27 3403:24-29 3420:24-29 3437:22-27
ERROR in ./node_modules/axios/lib/platform/browser/index.js 3:0-36
Module not found: Error: Can't resolve './classes/Blob.js' in '/tmp/build_64aff3bc/node_modules/axios/lib/platform/browser'
@ ./node_modules/axios/lib/platform/index.js 1:0-39 6:5-13
@ ./node_modules/axios/lib/defaults/index.js 8:0-44 139:14-39 140:10-31
@ ./node_modules/axios/lib/axios.js 7:0-43 47:29-37
@ ./node_modules/axios/index.js 1:0-35 23:4-9 25:0-43:1
@ ./src/main.js 2:0-26 566:8-38 573:8-53 622:41-46 680:26-31 797:47-52 819:49-54 856:29-34 888:21-26 916:22-27 963:22-27 987:22-27 1028:22-27 1069:22-27 1105:22-27 1141:22-27 1165:22-27 1193:22-27 1216:22-27 1256:22-27 1293:22-27 1319:34-39 1333:25-30 1364:22-27 1390:31-36 1426:27-32 1455:24-29 1477:24-29 1496:24-29 1534:31-36 1548:25-30 1587:22-27 1607:22-27 1632:22-27 1660:22-27 1688:22-27 1716:22-27 1747:22-27 1781:22-27 1837:24-29 3262:22-27 3286:22-27 3315:22-27 3333:22-27 3350:22-27 3368:22-27 3386:22-27 3403:24-29 3420:24-29 3437:22-27
ERROR in ./node_modules/axios/lib/platform/index.js 2:0-43
Module not found: Error: Can't resolve './common/utils.js' in '/tmp/build_64aff3bc/node_modules/axios/lib/platform'
@ ./node_modules/axios/lib/defaults/index.js 8:0-44 139:14-39 140:10-31
@ ./node_modules/axios/lib/axios.js 7:0-43 47:29-37
@ ./node_modules/axios/index.js 1:0-35 23:4-9 25:0-43:1
@ ./src/main.js 2:0-26 566:8-38 573:8-53 622:41-46 680:26-31 797:47-52 819:49-54 856:29-34 888:21-26 916:22-27 963:22-27 987:22-27 1028:22-27 1069:22-27 1105:22-27 1141:22-27 1165:22-27 1193:22-27 1216:22-27 1256:22-27 1293:22-27 1319:34-39 1333:25-30 1364:22-27 1390:31-36 1426:27-32 1455:24-29 1477:24-29 1496:24-29 1534:31-36 1548:25-30 1587:22-27 1607:22-27 1632:22-27 1660:22-27 1688:22-27 1716:22-27 1747:22-27 1781:22-27 1837:24-29 3262:22-27 3286:22-27 3315:22-27 3333:22-27 3350:22-27 3368:22-27 3386:22-27 3403:24-29 3420:24-29 3437:22-27
5 errors have detailed information that is not shown.
Use 'stats.errorDetails: true' resp. '--stats-error-details' to show it.
webpack 5.89.0 compiled with 5 errors in 11223 ms
-----> Build failed
We're sorry this build is failing! You can troubleshoot common issues here:
https://devcenter.heroku.com/articles/troubleshooting-node-deploys
Some possible problems:
- node_modules checked into source control
https://devcenter.heroku.com/articles/node-best-practices#only-git-the-important-bits
- Node version not specified in package.json
https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
Love,
Heroku
! Push rejected, failed to compile Node.js app.
! Push failed
javascript node.js heroku webpack newrelic
1个回答
0
投票

可能已经解决了这个问题。正在从节点模块导入 axios 以捆绑到前端,并且似乎 webpack 构建环境有所不同。使用浏览器的缩小 axios 代码并将其放置在单独的文件中,然后将其导入到将捆绑的文件中。 认为这与 axios webpack 对新版本的兼容性有关,因为当我使用可观察性模块时,它们似乎也尝试支持新版本,这会导致捆绑时出现问题。使用 1.1.2,但当可观察性模块出现时,两者都使用最新版本,同时维护 1.1.2。

不确定 Heroku 环境有何不同会导致此问题,但使 axios 成为预构建的缩小包导入是有效的。

© www.soinside.com 2019 - 2024. All rights reserved.