For the course project, we use 3rd party packages that are created by some developer or community. The developer/community constantly updates the packages. We can update the npm packages with the new version as there might be a bug fixture.
Please note that don't update the npm package of the project unless you actually know that it will not break your code.
In the course project, you can view the list of packages in the package.json
file present at the root of the folder.
Before getting started, make sure you have the latest version of npm installed on your system For that, you can execute the below command in the terminal.
npm install -g npm@latest
To check what outdated packages, you can execute the below command in the terminal.
npm outdated
After executing the above command, you can view the list of outdated packages for the project as in the image below.
As shown in the above image, we have four outdated packages.
To update the npm packages, you can install the npm package npm-check-updates
on your system. For that, we can execute the below command in the terminal.
npm i -g npm-check-updates
To update the package.json
, you can execute the below command in the terminal.
ncu --loglevel verbose --packageFile package.json
ncu -u --packageFile package.json
The above command updates the package's version number in package.json
information but does not install the packages.
As shown in the below image, how we can quickly update the npm packages by executing a few commands in the terminal.
Always remember that the above command only updates the npm version number in the package.json
. To install the packages, you can execute the below command in the terminal.
npm install
After installing the npm packages, re-develop the project by executing the command npm run develop
in the terminal.