flatMap不是Webpack >5.84.0的函数

cl25kdpy  于 2023-05-29  发布在  Webpack
关注(0)|答案(1)|浏览(234)

我正在学习一个关于webpack的教程,在开始的时候遇到了一个错误,同时试图让webpack编译。
安装webpack和webpack-cli后,我在尝试运行构建脚本时遇到以下错误:

[webpack-cli] TypeError: ["webpack.config",".webpack/webpack.config",".webpack/webpackfile"].flatMap is not a function
    at WebpackCLI.loadConfig (C:\Users\xxxxxxxxxx\Documents\Repositories\webpack-starter\node_modules\webpack-cli\lib\webpack-cli.js:1439:15)    at WebpackCLI.createCompiler (C:\Users\xxxxxxxxxxx\Documents\Repositories\webpack-starter\node_modules\webpack-cli\lib\webpack-cli.js:1714:33)
    at WebpackCLI.runWebpack (C:\Users\xxxxxxxxxxx\Documents\Repositories\webpack-starter\node_modules\webpack-cli\lib\webpack-cli.js:1810:31)    at Command.makeCommand (C:\Users\xxxxxxxxxxx\Documents\Repositories\webpack-starter\node_modules\webpack-cli\lib\webpack-cli.js:892:32)   
    at Command.listener [as _actionHandler] (C:\Users\xxxxxxxx\Documents\Repositories\webpack-starter\node_modules\webpack-cli\node_modules\commander\lib\command.js:482:17)
    at actionResult._chainOrCall (C:\Users\xxxxxxxxxxx\Documents\Repositories\webpack-starter\node_modules\webpack-cli\node_modules\commander\lib\command.js:1283:65)
    at Command._chainOrCall (C:\Users\xxxxxxxxxxxxx\Documents\Repositories\webpack-starter\node_modules\webpack-cli\node_modules\commander\lib\command.js:1177:12)
    at Command._parseCommand (C:\Users\xxxxxxxxxxxxx\Documents\Repositories\webpack-starter\node_modules\webpack-cli\node_modules\commander\lib\command.js:1283:27)
    at hookResult._chainOrCall (C:\Users\xxxxxxxxx\Documents\Repositories\webpack-starter\node_modules\webpack-cli\node_modules\commander\lib\command.js:1081:27)
    at Command._chainOrCall (C:\Users\xxxxxxxxxxxx\Documents\Repositories\webpack-starter\node_modules\webpack-cli\node_modules\commander\lib\command.js:1177:12)
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! webpack-starter@1.0.0 build: `webpack --mode production`       
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the webpack-starter@1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\xxxxxxxx\AppData\Roaming\npm-cache\_logs\2023-05-26T14_49_54_605Z-debug.log

当我从5.84.0降级到webpack 5.70.0和webpack-cli从5.0.1降级到4.9.2时,错误消失了。
有没有可能得到一个非常简单的npm构建与当前版本的webpack一起工作,或者它是一个无法修复的破坏性变化?

whitzsjs

whitzsjs1#

我实际上只是遇到了这个问题,可能来自同一个教程。我试着像你一样降级这些依赖关系,但我没有成功。我最终安装了最新版本的node,在撰写本文时是18.16。这样做解决了我的问题。在这个问题上,我使用的是一个更老的版本,类似于版本10.23。

相关问题