srs/gradle-node-plugin

NPM Cache Config fails on second run

oobles opened this issue · 2 comments

plugins {
id "com.moowork.node" version "1.3.1"
}
task npmCacheConfig(type: NpmTask) {
description = "Configure the NPM cache"
def npmCacheDir = "${gradle.getGradleUserHomeDir()}/caches/npm/"
outputs.files file(npmCacheDir)
args = ['config', 'set', 'cache', npmCacheDir]
}

When using a npmCacheConfig task like above using Gradle 5.5.1 we get the following error on the second run. The first run successfully creates and uses the directory, however, the second run fails.

  • What went wrong:
    A problem was found with the configuration of task ':some-project:npmCacheConfig'.

Cannot write to file '/.../caches/npm' specified for property '$1' as it is a directory.

Is there a different method that should be used for configuring the NPM cache?

deepy commented

Shouldn't that be outputs.dir rather than outputs.files?

Yes. That was it! Thanks, was staring at it all day and knew it should be something simple.