Npm publish latest - npm

I published a new version of my package (0.3.2) but it is not the latest one.
npm view give me:
{
'dist-tags': { latest: 0.3.1}
versions: [..., 0.3.2],
time: {..., '0.3.2': '2016-...'},
version: '0.3.1',
...
}
I get an NPM error:
"You cannot publish over the previously published version 0.3.2"

Because i didn't use npm publish (--tag latest) but npm publish --tag pkg#0.3.2, my version 0.3.2 is freezed on the NPM registry without being the latest one. NPM does not have any way to rollback, the only workaroud is to bump the version (0.3.3 in my case).

Related

I published new version of npm package, Npm shows new version, but installing older version

I have updated my npm library by publishing a new version. it has been 3 hours. The readme got updated in the npm page. But when i install, i am getting an older version.
https://www.npmjs.com/package/notiboy-js-sdk
1.0.0 is updated in the npm page. But when i install, i am getting older version.

NPM not installing latest version of package

Steps to reproduce:
npm init
npm i react-syntax-highlighter
{
"dependencies": {
"react-syntax-highlighter": "^15.4.3"
}
}
I have the latest version, hourra !
npm init
npm i #storybook/components
npm i react-syntax-highlighter
{
"dependencies": {
"#storybook/components": "^6.2.9",
"react-syntax-highlighter": "^13.5.3"
}
}
Wtf ? It took me 2h and a lot of luck to find out I had not the latest package of react-syntax-highlighter, and it seem it is because #storybook/components use react-syntax-highlighter#13.5.3.
I find it completely non-intuitive that npm i <package_name> would not always install latest. Why is NPM designed that way ? And how can I configure NPM to always download the latest when I do npm i <package_name>. Basically making #latest the default behavior (I thought it was default).
Because the author of storybookjs/storybook version 6.2.9 of his package to specific version of a dependent package.
https://github.com/storybookjs/storybook/blob/e74c0b7514b58c1308400958275e1623ea973f0d/lib/components/package.json#L58

Correct version of NPM to use?

When I go to https://www.npmjs.com/package/npm it shows 4.4.4 as the latest release.
When I go to the link from that page to https://github.com/npm/npm I see 4.5.0.
Does this mean 4.4.4 is a stable release and 4.5.0 is not stable?
I should use 4.4.4?
You can view the package distribution tags for npm by running this command:
npm view npm dist-tags
The output of which is:
{ latest: '4.4.4',
next: '4.5.0',
'latest-2': '2.15.11',
'v3.x-latest': '3.10.10',
'3.x-latest': '3.10.10',
'3.x-next': '3.10.10',
'v3.x-next': '3.10.10',
'next-2': '2.15.12',
'latest-1': '1.4.29',
lts: '2.15.11',
'latest-3': '3.10.10',
'next-3': '3.10.10' }
So the latest version is indeed 4.4.4 and - as you have surmised - the next version is 4.5.0. You should probably install 4.4.4, but it's up to you.
If you decide to install 4.5.0, you can do so using npm install -g npm#4.5.0 or npm install -g npm#next.

How to find the latest stable version of an npm package?

This question covers how to get the npm CLI to show the latest version of a package:
npm view [PKG_NAME] version
But if I do npm view async version I get 2.0.0-rc.6, which is a release candidate.
Is there a command that will tell me the current stable version?
If you want to list only the stable versions not the beta then
npm view bootstrap#* version
to install the latest stable version
npm install bootstrap#*

How do I update an NPM module that I published?

I created a NPM module and I published it at version 0.0.1
I made some changes and pushed those to github, and I would like it so that when one uses npm install myModule the new version is used.
How do I tell NPM that there is a version 0.0.2?
Change the version in your package.json or use npm version <new-version>.
After changing the version number in your package.json, you can run npm publish to publish the new version to NPM.
npm install will install the latest version in the NPM repository.
Increase the version number and then run npm publish yourModule again - as described in the npm docs.
npm install yourModule will then install the latest version from the NPM registry.
I found the last answer a little misleading, sorry.
For me, updating the version in the package.json still resulted in the "You cannot publish over..." error.
The steps to resolve were (based on ops version number):
npm version 0.0.2
npm publish
If it is an patch release (small changes) use following:
npm version patch
It will increment the last part of version number.
If it is a minor release (new features) use following:
npm version minor
It will increment the middle part of version number.
If it is a major release (major features or major issue fixes) use following:
npm version major
It will increment the first part of version number.
From the npmjs documentation:
To change the version number in package.json, on the command line,
in the package root directory, run the following command, replacing
<update_type> with one of the semantic versioning release types
(patch, major, or minor):
npm version <update_type>
Run npm publish.
Go to your package page (https://npmjs.com/package/) to check that the package version has been updated.