Table of Contents
I work on monorepo setting up changesets to a project and found a problem when working with pre-release versions.
changesets is a versioning and changelogs for monorepo. By writing impacts and change descriptions in markdown changesets file with commits, Changeset will collect these files to determine which package to bump, versioning, create changelogs, and publish package to registry automatically. The only manual work is writing a change file.
Semantic version has pre-release version specs for an unstable build. The format is something like this
1.0.0-alpha.1 in my case is
Everything seems fine. I setup changesets. Make a first changes. Write a changesets file. Push commit to remote. Pipeline run. Changesets tags and push
0.1.0-beta.1 to private registry. Everything works as expected. Nothing to worry. I work on other work.
Sometime later. I make an another change. Push commit to remote.
Pipeline GREEN. But I notice something in the CI log.
🦋 info npm info @nitpum/ui
🦋 warn Received 404 for npm info "@nitpum/ui"
🦋 info @nitpum/ui is being published because our local version (0.1.0-beta.1) has not been published on npm
Look like changesets can’t find my package on the registry and try to publish
0.1.0-beta.1 to the registry again because it think this version never published and this is the first times.
But how it can’t find the existing version?
After some investigation, I found that changesets use npm info underlying.
npm info is a command to get package information e.g. description, dependencies, dist-tags, etc. The command is same as npm view
npm info <package-name>
Changesets implemented code like this
Changesets check the stdout if returns empty, assume that it run on Github actions and package not exists. Normally, npm info never returns empty string on stdout.
But these is a case that can returns empty string.
If your package is published pre-release version and never published stable version yet, Looks like the registry can’t get package info because no info from stable version so it returns empty string instead (package info is empty)
Publish a stable version to registry once then
npm info will return package info with pre-release version info correctly, instead of empty string.