What is the practical difference between npm install
and npm update
? When should I use which?
The difference between npm install and npm update handling of package versions specified in package.json:
{
"name": "my-project",
"version": "1.0", // install update
"dependencies": { // ------------------
"already-installed-versionless-module": "*", // ignores "1.0" -> "1.1"
"already-installed-semver-module": "^1.4.3" // ignores "1.4.3" -> "1.5.2"
"already-installed-versioned-module": "3.4.1" // ignores ignores
"not-yet-installed-versionless-module": "*", // installs installs
"not-yet-installed-semver-module": "^4.2.1" // installs installs
"not-yet-installed-versioned-module": "2.7.8" // installs installs
}
}
Summary: The only big difference is that an already installed module with fuzzy versioning ...
npm install
npm update
Additionally: install
and update
by default handle devDependencies differently
npm install
will install/update devDependencies unless --production
flag is addednpm update
will ignore devDependencies unless --dev
flag is addedWhy use npm install
at all?
Because npm install
does more when you look besides handling your dependencies in package.json
.
As you can see in npm install you can ...
PATH
) using npm install -g <name>
--force