How to update Nest.js (2022)
source link: https://blog.bitsrc.io/how-to-update-nest-js-ecd0e9466165
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
How to update Nest.js (2022)
In this article, I want to talk about Nest.js and how you update it with two packages you need to have installed.
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
$ 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:
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.1Run 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.7Run 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!
Recommend
-
43
-
4
Nest x Yale smart lock becomes dumb with Nest Hub Max Preview Update bug
-
91
How to enable CORS in Nest.js (2022)A brief guide on how to enable CORS in Nest.jsIn this article, I want to quickly explain how to enable CORS in Nest.js without installing any additional package.
-
5
Inject Service from another Module in Nest.js (2022)I often read the question of how to inject a service/provider from another module. In this article, I wanna explain how to deal with this inside Nest.js’s dependency inve...
-
3
Google finally remembers to update the first-gen Nest Hub with its new app drawer By Will Sattelberg Published 9 hou...
-
2
Google has added an app launcher to the original Nest Hub with the latest update
-
4
Google’s Matter update for the Nest Hub Max will break direct Nest x Yale Lock integration Anyone with a Nest x Yale Lock connected directly to the Max will get a free Nest...
-
9
Google's Nest Hub Max gets Fuchsia update in Preview Program, here's how to opt in By Ryne Hager Published 5 hours ago
-
2
Google’s rolling out a Nest Wifi Pro update to fix slow internet speeds / The company says only ‘a small number of users’ are experiencing reduced internet speeds with the new router. It’s rolling out a software updat...
-
6
New update turns your Google Nest into a Matter control hub
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK