我有一个包含JVM和JS的Kotlin多平台项目。当执行jsRun
gradle任务来启动webpack服务器时,它会失败并显示以下错误信息:
Waiting for changes to input files of tasks... (ctrl-d then enter to exit)
[webpack-cli] TypeError: cli.isMultipleCompiler is not a function
[webpack-cli] TypeError: cli.isMultipleCompiler is not a function
at Command.<anonymous> (C:\MyProject\build\js\node_modules\@webpack-cli\serve\lib\index.js:146:35)
at async Promise.all (index 1)
at async Command.<anonymous> (C:\MyProject\build\js\node_modules\webpack-cli\lib\webpack-cli.js:1687:7)
编译成功,我可以通过Ktor提供的项目服务,但问题似乎出在webpack开发服务器上。
kotlin gradle插件生成的package.json
似乎使用了webpack-cli 4.9.0
。
{
"name": "MyProject-client",
"version": "1.0.0",
"main": "kotlin/MyProject-client.js",
"devDependencies": {
"sass-loader": "13.0.0",
"sass": "1.53.0",
"style-loader": "3.3.1",
"css-loader": "6.7.1",
"resolve-url-loader": "5.0.0",
"webpack": "5.57.1",
"webpack-cli": "4.9.0",
"format-util": "1.0.5",
"source-map-loader": "3.0.0",
"webpack-dev-server": "4.3.1",
"dukat": "0.5.8-rc.4"
},
"dependencies": {},
"peerDependencies": {},
"optionalDependencies": {},
"bundledDependencies": []
}
这篇文章指出这是webpack-cli 4.9.0
的一个 bug,并建议升级到 4.10.0
。我不知道 Kotlin/JS 中如何更改 webpack 版本。