Change registry url in gradle node plugin

4.5k views Asked by At

I am using gradle with gradle-node-plugin. The problem is that I don't have access to public registers so node cannot download anything from https://registry.npmjs.org/. I need to use nexus as proxy butt don't know how to change url to which npm is pointing. Does anyone know the solution?

2

There are 2 answers

2
Eric Wendelin On BEST ANSWER

I believe the Gradle Node Plugin executes npm itself to resolve modules so just updating your .npmrc with registry=https://npm.yourcompany.com ought to work.

Note that this is basically what npm config set registry does, as RaGe suggested in his comment.

0
MGothe On

If you want to do this directly in a gradle task you can use the following:

task setregistry(type: NpmTask) {
  args = ['config', 'set', 'registry', 'https://npm.registry.company.com']
}

You can also do this if you want to set the registry for a specific scope:

task setregistry(type: NpmTask) {
  args = ['config', 'set', '@scope:registry', 'https://npm.registry.company.com']
}