Configuring nodeModulesDir in gradle-node-plugin

寵の児 提交于 2019-12-04 13:04:59

I have fixed it this way:

npmCacheConfig.doFirst {
    def nodeJsDirectory = null
    def nodeVersion = this.project.node.version

    file("$webAppSourceAbsolute/nodejs/").traverse(
            type: FileType.DIRECTORIES,
            nameFilter: ~"^node-v$nodeVersion.*",
            postDir: {
                return FileVisitResult.TERMINATE
            }
    ) {
        nodeJsDirectory = it
    }

    if (nodeJsDirectory != null) {
        this.project.node.nodeModulesDir = file("$nodeJsDirectory/lib/")
    } else {
        throw new IllegalStateException("nodejs is not installed")
    }
}


npmCacheConfig.doLast {
    this.project.node.nodeModulesDir = file("$webAppSourceAbsolute/")
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!