我真的不知道是什么问题。 我想要的是,当项目构建时,它的工作方式就像输入命令“npm install”。 这个错误发生在构建时。 请帮助我。
这是错误消息。
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':web:npmInstall'.
> A problem occurred starting process 'command 'npm''
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 3s
6 actionable tasks: 6 executed
5:37:28: Task execution finished 'build'.
这是 build.gradle.kts 文件。
plugins {
id("com.moowork.node") version "1.3.1"
id("com.github.node-gradle.node") version "2.2.3"
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-thymeleaf")
implementation("nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect:3.1.0")
developmentOnly("org.springframework.boot:spring-boot-devtools")
implementation(project(":domain"))
implementation(project(":common"))
}
tasks.getByName("bootJar"){
enabled = false
}
tasks.getByName("jar"){
enabled = true
}
buildscript {
repositories {
maven {
url = uri("https://plugins.gradle.org/m2/")
}
gradlePluginPortal()
}
dependencies {
classpath("com.moowork.gradle:gradle-node-plugin:1.3.1")
classpath("com.github.node-gradle:gradle-node-plugin:2.2.3")
}
}
apply(plugin = "com.moowork.node")
apply(plugin = "com.github.node-gradle.node")
configure<com.moowork.gradle.node.NodeExtension> {
version = "21.1.0"
npmVersion = "10.2.0"
isDownload = true
workDir = file("C:/Program Files/nodejs")
npmWorkDir = file("C:/Program Files/nodejs")
nodeModulesDir = project.file("${projectDir}/src/main/resources/static")
}
val npmInstall by tasks.getting(com.moowork.gradle.node.npm.NpmTask::class) {
dependsOn.clear()
doLast {
exec {
commandLine("npm", "install")
}
}
}
val copyFrontLib by tasks.registering(Copy::class) {
from("${projectDir}/src/main/resources/static")
into("${projectDir}/build/resources/main/static/.")
dependsOn(npmInstall)
}
tasks.getByName("compileJava").dependsOn(copyFrontLib)
我无法理解问题所在。 所以我对这个问题无能为力。 请帮助我。