×
Clear all filters including search bar
Valeri Tandilashvili's NPM Notes
npm install / npm i
Shows current version of npm
npm --version / npm -v
Creates package.json file with default valuesnpm init --yes / npm init -y
Installs package moment npm install moment --save / npm i moment -S
Installs package lodash for dev environment npm install lodash --save-dev / npm i moment -D
Installs package live-server globally so that other apps can use itnpm install --global live-server / npm i -g live-server
Other shortcuts - https://docs.npmjs.com/misc/confignode_modules that are extraneous packages (that are not listed in package.json)npm prune
Before running the above command, npm list --depth 0 showed several packages as extraneous.
Extraneous are packages that are not listed in dependencies or devDependencies but installed in node_modules)+-- gulp@4.0.2 extraneous
+-- gulp-sass@4.1.0 extraneous
`-- moment@2.27.0npm install moment@2.25.2
Installs the specified module with the latest patch npm install moment@2.25
Installs the specified module with the latest minor and patch versions npm install moment@1
Installs the latest version of the module (with latest major, minor and patch versions)npm install momentmajor version will stick to 1 but minor and patch will be the latest versions"dependencies": {
"moment": "^1.6.2"
}
Only updates patch but major and minor will be the specified versions"dependencies": {
"moment": "~1.6.2"
}
Exactly the specified version 1.6.2 will be installed"dependencies": {
"moment": "1.6.2"
}
The latest version of the package will be installed"dependencies": {
"moment": "*"
}npm list --global --depth 0npm list --depth 0
Shows all packages with only their dependencies (one level deep)npm list --depth 1scripts key, inside package.json file.
If the content is the following"scripts": {
"start": "node app.js",
"server": "live-server"
}Then we can run npm run start and npm will run node app.js
We can also run npm run server and it will run live-serverISC)npm config delete init-license
Deletes manually set default author name (default author will become empty string)npm config delete init-author-namename - name of the app (default is the name of the current folder)
version - version of the app (default is 1.0.0 - major.manor.patch)
description - short description for the project
main - entry point - main JS file
keywords - keywords that the app is related to
author - project author
license - default is ISC (Internet Systems Consortium)npm install command (in console)npm install -h
Alternative to the above commandnpm install --help