34
loading...
This website collects cookies to deliver better user experience
package-lock.json
is locking/pinning a specific version of a package. On a regular basis these records need to be updated to pull the latest compatible version.npm outdated
in the root folder (where the package.json file is). This command will output the current installed versions of all packages, the wanted version (npm update
would want to update to this version), and the latest available version. For example, we have the following package.json (created with npm init -y
and version 4.8.1 of lodash installed):{
"name": "node-test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"lodash": "^4.8.1"
}
}
npm outdated
we get the following output:Package Current Wanted Latest Location
lodash 4.8.1 4.17.21 4.17.21 node-test
npm update
. If you just want to update one package you have to specify the package npm update <package-name>
.# Updates all dependencies in project.
npm update
# Update just the lodash package.
npm update lodash
--global
flag in the update command.npm update --global <package-name>
package.json
and package-lock.json
have to be committed to version control (GIT).npm update
the version ranges in package.json will be respected. Typically, updates to a major version are not allowed. If you'd like to update to a major release, use npm install
with the tag @latest
. This will install the latest version regarding of which version you already have installed.lodash
.npm install lodash@latest
npm outdated
.npm update
.npm update <package-name>
.@latest
flag - npm install <package-name>@latest
.