gpt4 book ai didi

java - Gradle 无法执行 npm 命令

转载 作者:塔克拉玛干 更新时间:2023-11-03 03:20:24 24 4
gpt4 key购买 nike

我正在尝试在 gradle 任务中运行 npm 命令,但出现了一个奇怪的错误:

Caused by: net.rubygrapefruit.platform.NativeException: Could not start 'npm'
at net.rubygrapefruit.platform.internal.DefaultProcessLauncher.start(DefaultProcessLauncher.java:27)
at net.rubygrapefruit.platform.internal.WrapperProcessLauncher.start(WrapperProcessLauncher.java:36)
at org.gradle.process.internal.ExecHandleRunner.run(ExecHandleRunner.java:65)
... 2 more
Caused by: java.io.IOException: Cannot run program "npm" (in directory "/Users/psilva/Documents/projects/registrolivre"): error=2, No such file or directory
at net.rubygrapefruit.platform.internal.DefaultProcessLauncher.start(DefaultProcessLauncher.java:25)
... 4 more
Caused by: java.io.IOException: error=2, No such file or directory

这是我的任务:

task npmInstall(type: Exec) {
commandLine "npm", "install"
}

有人可以帮忙吗?

最佳答案

如果你在 Windows 上试试这个:

task npmInstall(type: Exec) {
commandLine "npm.cmd", "install"
}

而不是这个:

task npmInstall(type: Exec) {
commandLine "npm", "install"
}

关于java - Gradle 无法执行 npm 命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35540126/

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