Versioning and Publishing Packages with Nx Release

This ad is not shown to multipass and full ticket holders
React Summit US
React Summit US 2026
November 17 - 20, 2026
New York, US & Online
Upcoming event
React Summit US 2026
React Summit US 2026
November 17 - 20, 2026. New York, US & Online
Bookmark
Rate this content
Sentry
Promoted
Code breaks, fix it faster

Crashes, slowdowns, regressions in prod. Seer by Sentry unifies traces, replays, errors, profiles to find root causes fast.

Get started

Learn to publish npm packages like a pro using the power of Nx. Starting from a basic repo with several packages, we'll establish a versioning strategy, changelog structure, and publishing workflow. Afterwards, we'll explore the many features and options of Nx release that allow you to adapt to your organization's processes.

This talk has been presented at DevOps.js Conf 2024, check out the latest edition of this JavaScript Conference.

FAQ

Austin Faisal is a core maintainer of Lerna, a member of the Nx core team, and has a background in enterprise web development.

Nx Release is used to improve versioning and publishing processes in a monorepo setup by picking new versions for packages, generating a workspace-level changelog file, and publishing all packages to a remote registry.

To initialize Nx in an existing repo, you need to install the NxJS plugin and answer a few setup questions. You should specify which packages you want to publish by configuring the project property under release in the NxJSON file.

A dry run in Nx Release performs all operations without actually writing any changes to disk, skipping all git operations and not publishing packages. It provides a preview of what would happen without making any actual changes.

The first release option indicates that this is the first time Nx Release is being run, so it skips validation around previous git tags and ensures packages exist in the remote registry.

Yes, Nx Release can create GitHub releases. The generated changelog files can be automatically pushed to GitHub releases pages if opted in.

The three major building blocks of Nx Release are version, changelog, and publish. These can be used individually or together in custom scripts.

More information about Nx Release, including detailed configuration options and use cases, can be found in the Nx.dev documentation.

Yes, Nx Release supports versioning packages independently, where each package can have a different version and not all packages need to be released at once. This requires additional configuration options.

Keeping all package versions in sync makes it easier for consumers to figure out which versions are compatible, as all packages will have the same version number. This is recommended for clarity and simplicity.

Austin Fahsl
Austin Fahsl
10 min
15 Feb, 2024

Comments

Sign in or register to post your comment.
Video Summary and Transcription
The video explores the use of Nx Release for improving package versioning and publishing processes. It starts with initializing Nx in an existing repository and selecting a new version for packages to ensure they remain in sync, which is crucial for maintaining compatibility. The process involves generating a workspace-level changelog file that includes all updates, such as added packages and bug fixes, and publishing packages to a remote registry. A dry run option is available to preview changes without committing them, allowing developers to verify updates before actual execution. Nx Release is designed for monorepo setups, supporting independent and automatic versioning with conventional commits. It can also create GitHub releases and offers a programmatic API for integration into custom automation scripts. The video emphasizes the importance of version synchronization, which simplifies compatibility management for consumers by maintaining consistent version numbers across packages.

1. Introduction to Nx Release

Short description:

Hi, my name is Austin Faisal. I'm a core maintainer of Lerna, a member of the Nx core team, and I'm going to show you how to level up your versioning and publishing process with Nx Release. We'll initialize Nx in an existing repo, pick a new version for our packages, generate a workspace-level changelog file, and publish all of our packages to the remote registry. Then we'll cover additional features that Nx Release has to offer. Let's get started.

Hi, my name is Austin Faisal. I'm a core maintainer of Lerna, a member of the Nx core team, and I have a background in enterprise web development. And I'm going to show you how to level up your versioning and publishing process with Nx Release.

First, we'll initialize Nx in an existing repo. Then we'll use Nx Release to pick a new version for our packages, generate a workspace-level changelog file, and publish all of our packages to the remote registry. Then we'll cover some additional features that Nx Release has to offer. Let's get started.

So we're starting from a basic JavaScript monorepo. It's using npm workspaces, and it has three packages, inventory, requests, and users. The first thing we're going to do is we're going to initialize Nx and we're going to install the NxJS plugin. So I'm going to answer a few of these questions. None of the scripts need to be run in order, so I'll go ahead and hit enter. None are cacheable and I am not going to enable remote caching. However, I would definitely encourage you to look into remote caching for your own workspace because it can save a lot of time in CI and in your local workflow. But for this example, I'm going to stay focused on Nx Release and just go ahead and skip that.

Okay, now I'm going to go into the NxJSON file and we're going to tell Nx exactly which packages we want to publish. We're going to do this with the project property under release. This is important because even though Nx will see all of the projects in your repo, you don't necessarily want to publish all of them because you might have applications or end testing projects or other things that aren't npm packages that you want to publish. So in this case, we have three packages we want to publish. They're all under the packages folder and so we can use this glob to represent that.

Okay, and then let's go ahead and commit our changes so far. We'll do this so that we have a nice fresh working tree from here on. And then I'm going to go ahead and add one more change. I'm going to actually fix a nasty bug in the inventory data. And usually it's a lot harder to fix a bug than just add a comment, but this will work for what we need to do. So I'm going to go ahead and commit this change as well. And then now we can run Nx Release. So I'm going to go ahead and run Nx Release first release dry run. And these two options are very important. The first release option indicates to Nx that this is the first time we're running Nx Release.

2. Running Nx Release and Reviewing Changes

Short description:

The dry run option allows you to preview the changes without actually writing them to disk or publishing the packages. Nx Release keeps your packages in sync by default, ensuring easy compatibility for consumers. The package JSON files are updated with the new version, and dependencies are also updated. The generated changelog includes the added packages and the recent bug fix.

So it shouldn't worry about any validation around previous get tags or making sure that the packages exist in the remote registry. And the dry run option is going to perform this as a dry run. It's going to not actually write any changes to disk. It's going to skip all the get operations. It's not actually going to publish the packages. It's just going to give us a preview of what would happen if we didn't use dry run. And so this is very valuable when we're dealing with these really hard to undo operations like creating get tags, creating GitHub releases, publishing packages to the registry.

So I'm going to go ahead and run it. And I'm going to pick a minor version. So it's going to prompt for what kind of change is this. And I'm going to say minor. OK. So the command finished. And let's go back up to the top and see what happened. The first step is versioning. So it detects each of these three projects, inventory, requests, users. It reads the current version of each as 0.0.1 from the package JSON file. And then it writes the new version based on that minor bump we told it to do. The new version being 0.1.0 writes it to each of the three package JSON files. Now NxRelease will always keep your packages in sync by default. So whenever you want to increment the version of any of them, it will increment the version of all of them. And so you'll always be releasing the same version number for each of your packages. This is recommended because it makes it really easy for the consumers of your package to figure out which versions are compatible. Because if they've all got the same version number, it's just very, very clear.

So if we keep scrolling down, we can see the changes to the package JSON files. And you'll note that the requests package actually has a dependency on the users package. And that was updated as well by NxRelease. And then we get down here, we could see the changelog that would be generated. So the changelog has one feature, which is the feature in which I added the users requests and inventory packages previously. And then there's the fix that we just did to the inventory package.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

pnpm – a Fast, Disk Space Efficient Package Manager for JavaScript
DevOps.js Conf 2022DevOps.js Conf 2022
31 min
pnpm – a Fast, Disk Space Efficient Package Manager for JavaScript
pnpm is a fast and efficient package manager that gained popularity in 2021 and is used by big tech companies like Microsoft and TikTok. It has a unique isolated node module structure that prevents package conflicts and ensures each project only has access to its own dependencies. pnpm also offers superior monorepo support with its node module structure. It solves the disk space usage issue by using a content addressable storage, reducing disk space consumption. pnpm is incredibly fast due to its installation process and deterministic node module structure. It also allows file linking using hardlinks instead of symlinks.
Yarn 4 - Modern Package Management
JSNation 2022JSNation 2022
28 min
Yarn 4 - Modern Package Management
Top Content
Yarn is a package manager that focuses on stability, performance, and security. It offers unique features like plug and play installation, support for nonmodules, and the exec protocol. Yarn is committed to being a good citizen in the open-source community and contributes to fixing dependencies. It is part of the Node.js Loader's working group and advocates for Corepack. Yarn is still experimental but is improving its user experience and security features. Contributions are welcome, and switching to Yarn can improve performance in large projects.
Understanding Package Resolution in Node.js
Node Congress 2024Node Congress 2024
11 min
Understanding Package Resolution in Node.js
Top Content
In this Talk, the speaker discusses package resolution in Node.js, covering topics such as CommonJS, ES modules, package.json structure, and package.json loader. The Talk also touches on conditional loading and file extension resolution, module import and export, module type determination based on file extensions and package.json, module resolution strategies in Node.js, and tips for improving loading time in ESM applications.
Package Management in Monorepos
DevOps.js Conf 2024DevOps.js Conf 2024
19 min
Package Management in Monorepos
This Talk discusses pain points and effective package management in monorepos, including the use of hoisted or isolated layouts and the challenges of working with peer dependencies. It introduces the tool Bit, which addresses these issues and handles dependency management and version control. Bit enables automatic installation and management of dependencies, supports multiple versions of a peer dependency, and seamlessly updates components across different environments.
Vite - The Next Generation Frontend Tooling
React Advanced 2021React Advanced 2021
20 min
Vite - The Next Generation Frontend Tooling
VIT is a build tool that solves the problem of slow feedback loop speed by leveraging native support for ES modules in modern browsers. It allows you to write code as native ES modules and handles the parsing and serving of modules for you. VIT supports JavaScript, CSS, SAS, React, TypeScript, and TSX out of the box. It also allows for quick migration from CRA to VIT and can be used as a middleware in an existing Node.js server to enable server-side rendering.
Configurational Dependencies in pnpm
JSNation 2025JSNation 2025
25 min
Configurational Dependencies in pnpm
Introduced new feature in PNPM v10 called config dependency, allowing custom plugins. Centralizing configuration and dependencies management. Early installation of limited config dependencies in PNPM. Trusted dependencies for lifecycle scripts in PNPM. Versatility of pmpm hooks in configuration. Example of a config dependency for fixing type script issues. Discussion on project sustainability, security, contributors, and hiring prospects. Comparison of migration tools, hosting preferences, and package version restrictions.