Webpack构建失败,未打印错误信息



当我在我的项目上运行npx webpack时,我得到以下错误:

[webpack-cli] Failed to load '/the/path/to/my/project/webpack.config.babel.js' config
[webpack-cli] TypeError: String.prototype.startsWith called on null or undefined
at startsWith (<anonymous>)
at node:internal/errors:811:19
at Array.filter (<anonymous>)
at node:internal/errors:809:16
at prepareStackTrace (node:internal/errors:96:12)
at Module._extensions..js (node:internal/modules/cjs/loader:1138:38)
at Object.newLoader [as .js] (/the/path/to/my/project/node_modules/pirates/lib/index.js:104:7)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)

从错误中可以看到,我有一个webpack.config.babel.js文件和一个.babelrc文件用于配置。

我已经尝试调试构建,但是我在异常断点上得到的变量内容不是很有用。

看起来我即将得到一个有用的错误消息,但是然后一个字符串返回null,所以错误根本没有被打印出来。

.babelrc重命名为.babelrc.json,构建成功。

最新更新