srs / gradle-node-plugin

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

Please provide examples on how to provide configuration properties #283

Open eximius313 opened 6 years ago

eximius313 commented 6 years ago

I'd like to provide configuration to properties. Invoking this from the commmand line works fine: npm config set registry https://registry.npmjs.org npm config set strict-ssl false

When I try to provide it in npm_task:

task setRegistry(type: NpmTask) {
  //Set NPM Registry
  args = ['config', 'set', 'registry', 'https://registry.npmjs.org']
}

I get following error:

Specify configs in the ini-formatted file:
    /user/.npmrc
or on the command line via: npm <command> --key value
Config info can be viewed via: npm help config

so it is possible to pass values in npm <command> --key value fashion, but neither args = ['config', 'set', '--registry', 'https://registry.npmjs.org'] nor args = ['config', 'set', '--registry https://registry.npmjs.org'] works.

Could you please provide information in documentation on how to do it correctly?

jgriff commented 5 years ago

Facing same problem, curious if anyone has found a way to do this?

web-devel commented 5 years ago

@jgriff use .npmrc files instead: https://docs.npmjs.com/files/npmrc

eximius313 commented 5 years ago

@web-devel so every developer in project must create this file?

web-devel commented 5 years ago

@eximius313 you can place .npmrc in the root of your project and commit it (obviously you should not commit any auth info)

john3300 commented 5 years ago

I too am looking for a way to set the npm registry, but creating a .npmrc file doesn't make sense in my case. I am not creating my own Node project, I'm just using npm to download scripts/tools that I use during my build for validation purposes. I don't have anywhere to put a .npmrc file.

So how else can this be accomplished?