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#*
Related
I'm currently setting up pre-releases (under the dev tag) for a new npm package of mine.
In my staging environment, I want npm to always install the latest pre-release version of the 2.0.0 version. Therefore, I specified "<packagename>": ">=2.0.0-dev.0" in the package.json, but npm somehow always installs the 2.0.0-dev.20180806T153307Z.3eaa718.HEAD, even if I do a clean install with removed package-lock.json.
According to the semver-checker my constraint matches the pre-releases published to npm.
I finally found the problem. Because there was no previous non-dev release published to npm for this package, npm always installed the pre-release version connected to the latest tag (see the image above in the question). The solution is to simply publish a fake release under an older version, e.g. 1.9.9. Now, a clean npm install works like expected.
I know I can use below to see what my packages are outdated.
npm outdated
But how can I know what's the WANTED version of a package that I didn't install?
I also found below and it shows every version of their package but it does not show what versions were deprecated.
npm view XXX version
I need to install a beta version 3.0.0 of react-docgen.
Is it possible to install a beta version via npm?
Yes, it's possible to install a beta version using the # symbol. For example to install react-docgen (v3.0.0-beta7) run the following command:
npm install -g react-docgen#3.0.0-beta7
Further information about installing specific versions can be found in the npm-install documentation.
The syntax for npm install includes both of the following overloads:
npm install [<#scope>/]<name>#<tag>
npm install [<#scope>/]<name>#<version>
For tag, you can specify either #latest and #beta like this:
npm install #11ty/eleventy#latest # latest stable release
npm install #11ty/eleventy#beta # latest beta release
Interestingly, if you don't specify a tag, the default, set by your npm config, is #latest
You can also find out which versions are available by running npm view
npm view #11ty/eleventy
To install a specific beta version:
npm install -g react-docgen#3.0.0-beta7
//or
yarn global add react-docgen#3.0.0-beta7 // if you use yarn
P.S.:
In order to see all versions of a package (including alpha, beta , pre-release, release):
npm show <package> versions --json
Example:
npm show react-docgen versions --json
You can also install a certain version using a tag!
npm install <name>#<tag>
In order to see which tags are available for this package, you have to run:
npm view react-docgen
A tag can be used when installing packages as a reference to a version
instead of using a specific version number (alias)
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.
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.