【发布时间】:2020-06-18 06:12:56
【问题描述】:
task npmInstallPkg(type: NpxTask){
doLast{
//install node packages from package.json
dependsOn npmInstall
//install pkg globally
command = 'npm'
args = ['install', '-g', 'pkg']
}
}
每当我尝试执行上述任务时,都会出现以下错误:
A problem was found with the configuration of task ':npmInstallPkg'.
> No value has been specified for property 'command'.
我正在使用 "com.github.node-gradle.node" 插件版本 "2.2.4"。
我多次交叉检查了语法,但没有发现任何问题。 我通过引用https://github.com/node-gradle/gradle-node-plugin/blob/2.2.4/docs/node.md#executing-npm-commands-via-npx的插件文档来创建任务
我的节点配置块如下:
// gradle node plugin configuration
node {
// Version of node to use.
version = '10.14.1'
// Version of npm to use.
npmVersion = '6.4.1'
// Version of Yarn to use.
yarnVersion = '1.3.2'
// Base URL for fetching node distributions (change if you have a mirror).
distBaseUrl = 'https://nodejs.org/dist'
// If true, it will download node using above parameters.
// If false, it will try to use globally installed node.
download = true
// Set the work directory for unpacking node
workDir = file("${project.buildDir}/nodejs")
// Set the work directory for NPM
npmWorkDir = file("${project.buildDir}/npm")
// Set the work directory for Yarn
yarnWorkDir = file("${project.buildDir}/yarn")
// Set the work directory where node_modules should be located
nodeModulesDir = file("${project.projectDir}")
}
【问题讨论】:
标签: gradle build.gradle gradle-plugin gradle-node-plugin