task npmInstallPkg(type: NpxTask){
doLast{
//install node packages from package.json
dependsOn npmInstall
//install pkg globally
command = 'npm'
args = ['install', '-g', 'pkg']
}
}
Whenever I try to execute the above task, I get below error :
A problem was found with the configuration of task ':npmInstallPkg'.
> No value has been specified for property 'command'.
I am using the "com.github.node-gradle.node" plugin version "2.2.4".
I have cross checked the syntax multiple times and haven't been able to find anything wrong with it. I created the task by referencing the plugin documentation at https://github.com/node-gradle/gradle-node-plugin/blob/2.2.4/docs/node.md#executing-npm-commands-via-npx
My node cofiguration block is as follows :
// 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}")
}
It appears the error is because the gradle-node-plugin is not able to find the property
commandfornpmInstallPkgof typeNpxTask, which it expected while configuring the task itself. The only solution that worked for me was removing thedoLastblock.But not being able to define the
commandin thedoLastseemingly takes away the charge from me in that I am no more able to stop it from executing during the configuration phase. Ideally I would have wanted this to be able to execute during execution phase or when I manually called it.Though this solves my original issue, I am still looking for a way to call the task during execution phase.