Loading
Current section: nx 20 exercises
lesson

Defining which Projects to Version

In this video, we discuss how to handle errors and configure versioning in a monorepo.

We start by copying all of our packages to the build folder and running the build off of that.

Handling Errors

You might have noticed an error in the script, stating that there is no such file or directory

Loading lesson

Transcript

00:00 So we're now copying all of our packages over to this build folder and then running the build off of that. Now, one thing you might have noticed is that when you run the script, there's actually an error at some point in here where it says there's no such file or directory, which is the build package.json. And so what's happening behind the scenes here

00:18 is that this package.json is being picked up as a potential project to publish as well. However, we don't want to really publish that or version that. You can also see here, it is being incremented as a version, which is not what we want. And so we have different ways of doing that. We can, one, define this as private, because this is literally the root level project.json,

00:36 which we just need for our monorepo. And so if we run the release process again, that error should disappear. So you can now see it tries to publish, but we don't have any version running, and so therefore it didn't run. But another way you can do is to go into the nx.json and define which projects should be included in the publishing and releasing and versioning process.

00:56 And so you have a project array here where you can define here, for instance, all the packages star should be versioned. And so that would only include all the packages folder, all the projects that are in this packages folder here. You can also work here with glob patterns, negate the actual output to say, do not version a certain package, et cetera.

01:14 Like if you have docs or end-to-end packages in here, you might want to exclude those from the packaging process.