4

My company has a Nexus 3 server where we store all of our artifacts for a predominantly Maven environment. I'm trying to use Node to do the same things as Maven:

  1. Deploy to a snapshots or releases directory based on a non-hard-coded flag (could be in Jenkins job)
  2. Automatically append an additional version variable to snapshots so that it can be "overridden". Since Nexus only likes unique names, I'd need some way to store the built artifact as x.y.z-SNAPSHOT.1, then x.y.z-SNAPSHOT.2 so that a fetch of x.y.z-SNAPSHOT will pull the latest

Ideally, the only difference between build/deploying a SNAPSHOT and a RELEASE would be npm publish <snapshot/release indicator flag> and it could look up, in say the .npmrc file the URL, but use credentials defined on the machine doing the build/deploy (so that developers don't have master credentials). I'm having trouble setting this up. The NPM scope looks promising, but that may only apply to packages/projects that would have one scope and not conditional ones.

I've currently tried an npm publish --registry=<url>, but it failed with an error saying I need to use npm adduser. I'm unsure of exactly how to supply the credentials and which to give it (am I giving it credentials for the Nexus user to store the artifact, or is NPM simply not allowing the current user (Jenkins user) to publish?).

Art Vandelay
  • 391
  • 6
  • 16
  • Npm uses semantic versioning, so best thing to do would be to use pre-release versioning: https://semver.org/#spec-item-9. When Nexus gets cleanup tasks for npm it will likely be based on that convention. – rseddon Jun 05 '18 at 14:01
  • Possible duplicate of [Using SNAPSHOT in private NPM like in Maven](https://stackoverflow.com/questions/31156766/using-snapshot-in-private-npm-like-in-maven) – BuZZ-dEE Jul 03 '19 at 14:12

0 Answers0