How to Update Nest.js

How to update Nest.jsIn this article, I want to talk about Nest.js and how you update it with two packages you need to have installed.Photo by James Harrison on UnsplashWhat is Nest.js?Nest.js is a framework for building efficient, scalable Node.js web…

How to update Nest.js

In this article, I want to talk about Nest.js and how you update it with two packages you need to have installed.

Code
Photo by James Harrison on Unsplash

What is Nest.js?

Nest.js is a framework for building efficient, scalable Node.js web applications. It uses modern JavaScript, is built with TypeScript, and combines elements of OOP (Object Oriented Programming) and Dependency Injection. If you develop an API based on Node.js, then Nest.js is the way to go since 2018.

How to update Nest.js?

First, we install two packages @nestjs/cli and npm-check-updates globally or as so-called devDependency. In this article, we go for the global approach. We need npm-check-updates because the Nest.js CLI doesn’t cover every single package from Nest.js.

$ npm install -g @nestjs/cli npm-check-updates

Now we can update Nest.js with the Nest.js CLI.

$ nest update

or

$ nest update --force

The force flag basically removes your official Nest.js packages from our package.json and node_modules to reinstall them on the most latest version. Since I didn’t update Nest.js in my project for a while, my Git changes look like this:

Dependencies of my project

But we are not done yet. As I said, the Nest.js CLI doesn’t cover everything. So we can run two additional commands with the npm-check-updates package.

$ npm-check-updates "/@nestjs*/" -u

The command above updates other official Nest.js packages which are not covered by the nest update command.

My console output looks like this:

Upgrading package.json
[====================] 17/17 100%
@nestjs/cli         ^8.1.6  →  ^8.2.1     
@nestjs/schematics ^8.0.5 → ^8.0.6
@nestjs/testing ^8.2.4 → ^8.3.1
Run npm install to install new versions.

Great, right? Now we updated all official Nest.js packages. But yet, we are still not done. First of all, we can see, that we have to run npm install to install the updates, but we also want to update the unofficial Nest.js packages from other developers we might use. So what I gonna do next is this command.

$ npm-check-updates "/nestjs*/" -u

My console output looks like this:

Upgrading package.json
[====================] 17/17 100%
@ntegral/nestjs-sentry  ^3.0.6  →  ^3.0.7
Run npm install to install new versions.

Now I have updated one unofficial Nest.js package as well. To install all updates we have made with the npm-check-updates package, we need to run one last command:

$ npm install

What’s next?

After updating dependencies it’s always very important to test your code before you go into production.

Thanks for reading my article about how to update Nest.js. I hope, you could get something out of this article.

Cheers!

Use any component in all your projects

Up until now, you used to build features hidden inside larger projects.

But what if you were to develop independent features first, and then easily compose and manage them in many applications? Your development will become faster, more consistent, and more scalable every day. Create a component once, and truly use it anywhere to build anything.

OSS Tools like Bit offer a powerful developer experience for building independent components and composing them to applications. You can start small with a nice project, some shared components, or even trying out Micro Frontends. Give it a try →

An independent product component: watch the auto-generated dependency graph

Learn more


How to Update Nest.js was originally published in Bits and Pieces on Medium, where people are continuing the conversation by highlighting and responding to this story.


Print Share Comment Cite Upload Translate
APA
Kevin Vogel | Sciencx (2024-03-29T06:14:24+00:00) » How to Update Nest.js. Retrieved from https://www.scien.cx/2022/02/18/how-to-update-nest-js/.
MLA
" » How to Update Nest.js." Kevin Vogel | Sciencx - Friday February 18, 2022, https://www.scien.cx/2022/02/18/how-to-update-nest-js/
HARVARD
Kevin Vogel | Sciencx Friday February 18, 2022 » How to Update Nest.js., viewed 2024-03-29T06:14:24+00:00,<https://www.scien.cx/2022/02/18/how-to-update-nest-js/>
VANCOUVER
Kevin Vogel | Sciencx - » How to Update Nest.js. [Internet]. [Accessed 2024-03-29T06:14:24+00:00]. Available from: https://www.scien.cx/2022/02/18/how-to-update-nest-js/
CHICAGO
" » How to Update Nest.js." Kevin Vogel | Sciencx - Accessed 2024-03-29T06:14:24+00:00. https://www.scien.cx/2022/02/18/how-to-update-nest-js/
IEEE
" » How to Update Nest.js." Kevin Vogel | Sciencx [Online]. Available: https://www.scien.cx/2022/02/18/how-to-update-nest-js/. [Accessed: 2024-03-29T06:14:24+00:00]
rf:citation
» How to Update Nest.js | Kevin Vogel | Sciencx | https://www.scien.cx/2022/02/18/how-to-update-nest-js/ | 2024-03-29T06:14:24+00:00
https://github.com/addpipe/simple-recorderjs-demo