"Heroku "找不到模块'@babel/运行时/助手/内置/互操作要求默认值'



在将node.js容器部署到Heroku后,我得到了以下错误日志:

2020-08-30T00:12:15.679723+00:00 app[abb.1]: (node:3) UnhandledPromiseRejectionWarning: Error: Cannot find module '@babel/runtime/helpers/builtin/interopRequireDefault'
2020-08-30T00:12:15.679796+00:00 app[abb.1]: Require stack:
2020-08-30T00:12:15.679804+00:00 app[abb.1]: - /AirbnbBClone-Jeremy/packages/common/node_modules/yup/lib/index.js
2020-08-30T00:12:15.679810+00:00 app[abb.1]: - /AirbnbBClone-Jeremy/packages/common/dist/yupSchemas/user.js
2020-08-30T00:12:15.679811+00:00 app[abb.1]: - /AirbnbBClone-Jeremy/packages/common/dist/index.js
2020-08-30T00:12:15.679815+00:00 app[abb.1]: - /AirbnbBClone-Jeremy/packages/server/dist/modules/user/forgotPassword/resolvers.js
2020-08-30T00:12:15.679815+00:00 app[abb.1]: - /AirbnbBClone-Jeremy/packages/server/dist/utils/genSchema.js
2020-08-30T00:12:15.679815+00:00 app[abb.1]: - /AirbnbBClone-Jeremy/packages/server/dist/startServer.js
2020-08-30T00:12:15.679816+00:00 app[abb.1]: - /AirbnbBClone-Jeremy/packages/server/dist/index.js
2020-08-30T00:12:15.679816+00:00 app[abb.1]:     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1080:15)
2020-08-30T00:12:15.679816+00:00 app[abb.1]:     at Function.Module._load (internal/modules/cjs/loader.js:923:27)
2020-08-30T00:12:15.679817+00:00 app[abb.1]:     at Module.require (internal/modules/cjs/loader.js:1140:19)
2020-08-30T00:12:15.679817+00:00 app[abb.1]:     at require (internal/modules/cjs/helpers.js:75:18)
2020-08-30T00:12:15.679821+00:00 app[abb.1]:     at Object.<anonymous> (/AirbnbBClone-Jeremy/packages/common/node_modules/yup/lib/index.js:3:30)
2020-08-30T00:12:15.679821+00:00 app[abb.1]:     at Module._compile (internal/modules/cjs/loader.js:1251:30)
2020-08-30T00:12:15.679822+00:00 app[abb.1]:     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1272:10)
2020-08-30T00:12:15.679822+00:00 app[abb.1]:     at Module.load (internal/modules/cjs/loader.js:1100:32)
2020-08-30T00:12:15.679822+00:00 app[abb.1]:     at Function.Module._load (internal/modules/cjs/loader.js:962:14)
2020-08-30T00:12:15.679822+00:00 app[abb.1]:     at Module.require (internal/modules/cjs/loader.js:1140:19)
2020-08-30T00:12:15.679823+00:00 app[abb.1]:     at require (internal/modules/cjs/helpers.js:75:18)
2020-08-30T00:12:15.679823+00:00 app[abb.1]:     at Object.<anonymous> (/AirbnbBClone-Jeremy/packages/common/dist/yupSchemas/user.js:3:13)
2020-08-30T00:12:15.679823+00:00 app[abb.1]:     at Module._compile (internal/modules/cjs/loader.js:1251:30)
2020-08-30T00:12:15.679823+00:00 app[abb.1]:     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1272:10)
2020-08-30T00:12:15.679824+00:00 app[abb.1]:     at Module.load (internal/modules/cjs/loader.js:1100:32)
2020-08-30T00:12:15.679824+00:00 app[abb.1]:     at Function.Module._load (internal/modules/cjs/loader.js:962:14)
2020-08-30T00:12:15.679824+00:00 app[abb.1]: (Use `node --trace-warnings ...` to show where the warning was created)
2020-08-30T00:12:15.680346+00:00 app[abb.1]: (node:3) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
2020-08-30T00:12:15.680403+00:00 app[abb.1]: (node:3) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

我听说Babel的这个问题可以通过将Babel降级到7.0.0-beta.55来解决,但我在我的package.json中找不到它。我需要更改我的yarn.lock文件以降级吗?

我以前在Heroku部署NodeJS应用程序时遇到过这种情况。解决方案是将@babel/runtime放在dependencies列表中,而不是放在devDependencies中。不知何故,@babel/runtime需要与其他核心包一起发货。希望这有帮助!

最新更新