1

I am fairly new to versioning a library, I wanted to get a clarity on my concern and please explain how does npm work.

I am trying to build a library and publish it to my organization npm registry. Now I have an alpha release which is already available in nexus and I did an npm install and the library works fine.

Now I when I create a stable release and make the library available for my organisation to use, when this happens the version tag will be updated to v1.0.0 and when I do an npm install the latest stable version will be available.

Post this, if I create further more alpha builds the version now has an alpha build tag appended to the version. Now when I do an npm install in a fresh project setup which version will I get:

  • stable version
  • new alpha version

I am a new to this, if anyone can explain how npm install will work and what version will I get that will be super helpful.

Thanks

Hugo y
  • 1,421
  • 10
  • 20
Anupam Jagatdeo
  • 121
  • 1
  • 5
  • Maybe this answer will help: https://stackoverflow.com/questions/39206082/npm-version-to-add-alpha-postfix or https://stackoverflow.com/questions/50846170/how-to-generate-npm-release-candidate-version – fedeteka May 25 '20 at 17:49

1 Answers1

0

What npm i will do for you, depends on what you stated in package.json.

{
  "dependencies":{
  "foo":"1.0.0", //match version exactly
  "baz":">1.0.2", //must be greater than version
  "elf":"~1.2.3", //everything from 1.2.3 to <1.3.0
  "thr":"^1.2.3", //from 1.2.3 to <2.0.0
  }
}

More details here

If you want to know the exact version of the package installed after npm i you could look it up in package-lock.json

i474232898
  • 781
  • 14
  • 25
  • I am aware of how to use various versions from package.json. But I am having troubles understanding what happens when you have future alpha builds also available. When you try to fetch the package using `npm install `, which version will you be fetching, is it the stable version or the alpha version. I tried it from my end and it comes down to which ever is the latest npm pull that version. So even if you have an alpha build, npm does not care and it will fetch the alpha build. – Anupam Jagatdeo Jul 09 '20 at 05:48