I wrote a node package which contains breaking changes in the next release. Does there exist a way to notify developers about that via console while upgrading via npm?
I don't think there is a solution to inform the via console, but if your new version is given by an new "major" number, it should not break the code.
Breaking example
Client dependency: ~1.2.2
Your old version: 1.2.2
Your new version: 1.2.3
The client will upgrade to version 1.2.3.
Not breaking example
User dependency: ~1.2.2
Your old version: 1.2.2
Your new version: 1.3.0
The client will not upgrade.
Related
I am using angular 14 in my application with nestjs version ^9.0.0. Now the requirement is to use "nest-azure-ad-jwt-validator" package for some purpose. When I am trying to install version 4.0.0 of "nest-azure-ad-jwt-validator", npm is throwing compatibility issue with nestjs/common package and not able to resolve the dependency. It would help if someone tell what version of "nest-azure-ad-jwt-validator" I should use which is compatible with nestjs version 9. Check the link to see package information:
https://www.npmjs.com/package/nest-azure-ad-jwt-validator
I checked package details and it is showing version 4.0.0 as the latest one.
Error I am getting.
The actual version of "nest-azure-ad-jwt-validator" doesn't support nestjs version 9.
I just made a pull request on the repo to upgrade it: https://github.com/benMain/nest-azure-ad-jwt-validator/pull/50.
for now if you still want to use this package, you should stick with the nestjs 8 until the next release.
I have two versions of a package e.g.
#mycompany/mylob v2.0.0
and
#mycompany/mylib v3.0.0
version 3.0.0 has breaking changes from version 2.0.0 but we do not have the capacity to upgrade everything to 3.0.0 as of yet.
Another developer has upgraded an internal package e.g. #mycompany/utils to use version 3.0.0 and that is installed into our codebase so now we are getting compatibility errors when running the build as #mycompany/utils requires version 3.0.0 but the rest of the code in that repository wants version 2.0.0.
Is there a way with yarn/npm that I can install #mycompany/mylib v3.0.0 for #mycompany/utils and have the rest of the code refer to v2.0.0?
You can use custom alias installs:
npm i custom-name:#mycompany/mylib#3.0
You can change custom-name to any valid package name you want to use.
After that you can import the package with this alias name. e.g.:
require("custom-name")/ import * from "custom-name"
For npm install specific version, use npm install [package-name]#[version-number].
I have installed node LTS 14.17.2 via nodenv.
npm now tells me a newer version is available:
New major version of npm available! 6.14.13 → 7.19.1
My question is: Is it recommended to upgrade npm or should I stay with the version shipped with node LTS?
The npm cli is packaged with the node.js install as a convenience, but it is maintained by a different team of folks and has its own release cadence, so it can be updated even without installing new version of Node.js.
Read up on the new features and breaking changes of npm 7 on Github's Blog post about npm 7 and think about how it may affect your programs. You can always try it and switch back to an older version if you run into problems.
Generally, I suggest checking out the changelog for npm and to understand what has been updated and use that to help you decide. If there is a new breaking change that requires a new version of node, it should be indicated in the changelog.
In the package.json of my reactjs webpack project I specified the version number of a dependency that I wanted to download through a npm install as ^0.0.130 where the latest version of that dependency is 0.0.145.
But when I hit the npm install its downloading 0.0.130, not the latest version.
But when I specified the version number as ^0.0.145 its downloading the latest version of 0.0.145.
I cannot figure out why its not downloading the latest version though i used caret sign (^) with the eailer number.
Can anyone help me to figure out why this is not happening in the right way.
^0.0.145 matches the most recent ^0.x.x version
To upgrade to latest version for the 1.0.0 major release you will need to use something like^1.0.0
Yes, That can be happen.
After a component is publishing using npm publish command the latest version is usually the highest version number. But if a component is published using npm publish --tag latest that version is marked as the latest one. So though you published new versions after that the latest version will be the eariler version.
In above scenario they published 0.0.130 as the latest version using npm publish --tag latest. So though they published new versions after that, ^0.0.130 is the latest one.
0.0.145
.......
.......
.......
0.0.131
0.0.130 --------latest
0.0.129
0.0.128
0.0.127
I was reading up on versioning with npm, and apparently it provides a nice convenient command for bumping your package versions.
npm version [<newversion> | major | minor | patch | premajor | preminor | prepatch | prerelease]
prerelease
Lets say your package starts at version 0.0.0
npm version prerelease => 0.0.1-0
npm version prerelease => 0.0.1-1
Basically just bumps the number after the dash
prepatch
Starting from 0.0.0 using pre[major|minor|patch] instead...
npm version prepatch => 0.0.1-0
npm version preminor => 0.1.0-0
npm version premajor => 1.0.0-0
patch
Starting from 0.0.0 using patch...
npm version patch => 0.0.1
npm version patch => 0.0.2
I understand the rules for bumping major minor and patch versions, but what is the standard convention for versioning things prior to 1.0.0?
TLDR
I have not seen prelease versions utilized pre-1.0.0. It seems fairly pointless since the public API is not finalized yet. They become useful after 1.0.0 is released.
So when are prelease versions useful?
From semver.org:
Version 1.0.0 defines the public API. The way in which the version number is incremented after this release is dependent on this public API and how it changes.
and:
A pre-release version MAY be denoted by appending a hyphen and a series of dot separated identifiers immediately following the patch version. ...A pre-release version indicates that the version is unstable and might not satisfy the intended compatibility requirements as denoted by its associated normal version.
The conventions I have seen pre-1.0.0 include using patches for bug fixes/typos and minor versions for any significant modifications. The conventions are less strict pre-1.0.0 since no public API has been guaranteed yet.
Prelease versions come in handy when you want to share some early features with the community.
For example, at the time of this writing, the latest stable release of npm-check-updates is version 1.5.1. Some of the new features I have added have introduced backward-incompatible changes, so to conform to semver I will have to release them under 2.0.0. Yet, I don't want to release 2.0.0 as the latest stable version until it has been more thoroughly tested by the community. Thus, I have published a prerelease version (using npm publish --tag unstable) versioned at 2.0.0-alpha.1. Community members can install the prerelease version (with npm install -g npm-check-updates#unstable) to try out the latest features while a normal npm install -g npm-check-updates will continue to install the stable 1.5.1 version for most users. When the prerelease has proven itself, I can easily publish it as the new stable at 2.0.0.