node-gradle / gradle-node-plugin

Gradle plugin for integrating NodeJS in your build. :rocket:
Apache License 2.0
601 stars 117 forks source link

Support custom registry from project .npmrc in NpmSetupTask #238

Open Vampire opened 2 years ago

Vampire commented 2 years ago

The NpmSetupTask does not obey to the custom registry defined in .npmrc file of the project. An ~/.npmrc does work, but it would be nice if the custom registry defined in the project specific .npmrc would als be used for NpmSetupTask. Workaround is to use args to configure a custom registry.

christianblos commented 3 months ago

I just had a similar case. You could also use args to configure the .npmrc file you want to use. Like this:

tasks.named("npmSetup") {
    args.addAll(['--userconfig', "${project.projectDir}/.npmrc"])
}
Vampire commented 3 months ago

But then you would not have the normal user config considered. Besides that you can then right away use the args to configure the custom repository if you need to configure anyway. :-)

christianblos commented 3 months ago

I just wanted to mention this solution as an alternative. I'm using a custom registry together with the _auth config. So, I needed to include the whole .npmrc file instead of just adding --registry. But you're right, it would be nice if the project file would be used automatically.