gpt4 book ai didi

javascript - Kotlin 多平台 gradle 任务 "jsRun"给出错误 "[webpack-cli] TypeError: cli.isMultipleCompiler is not a function"

转载 作者:行者123 更新时间:2023-12-05 01:23:11 25 4
gpt4 key购买 nike

我有一个使用 JVM 和 JS 的 Kotlin 多平台项目。执行jsRun gradle task启动webpack server失败,报如下错误:

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 dev server。

kotlin gradle plugin 生成的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": []
}

This说这是 webpack-cli 4.9.0 中的错误并建议升级到 4.10.0。我不知道是否/如何在 Kotlin/JS 中更改 webpack 版本。

最佳答案

这应该添加到受影响项目中的 build.gradle.kts 以强制使用 webpack-cli 版本。在 Kotlin 团队更新硬编码版本之前,这是一种解决方法。

// Fixes webpack-cli incompatibility by pinning the newest version.
rootProject.extensions.configure<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension> {
versions.webpackCli.version = "4.10.0"
}

关于javascript - Kotlin 多平台 gradle 任务 "jsRun"给出错误 "[webpack-cli] TypeError: cli.isMultipleCompiler is not a function",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72731436/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com