33 lines
958 B
Markdown
33 lines
958 B
Markdown
---
|
|
title: "update npm packages to latest versions"
|
|
seo_description: "How to update the node modules of a project to their latest version"
|
|
date: 2022-06-15T09:28:28+02:00
|
|
draft: false
|
|
snippet_types:
|
|
- npm
|
|
- js
|
|
- node
|
|
---
|
|
|
|
I was doing some housekeeping on a Node.JS project today. Wanted to update all
|
|
the dependencies to their latest versions. At first I tried `npm update` but
|
|
come to find out that is ment more for upgrading single packages and not
|
|
major versions. In the end after some googling I found
|
|
[npm-check-updates](https://www.npmjs.com/package/npm-check-updates).
|
|
|
|
To upgrade the dependencies of a project without installing anything else I ran:
|
|
|
|
```shell
|
|
$ npx npm-check-updates -u
|
|
```
|
|
|
|
It updated the **package.json** so it must be followed up by a:
|
|
|
|
|
|
```shell
|
|
$ npm i
|
|
```
|
|
|
|
Which will install the new packages and update the **package-lock.json**.
|
|
|
|
[source](https://nodejs.dev/learn/update-all-the-nodejs-dependencies-to-their-latest-version)
|