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.0
npm install npm@latest -g
npm list --global --depth 0
ISC
)npm config delete init-license
Deletes manually set default author name (default author will become empty string)npm config delete init-author-name
update
npm install
command (in console)npm install -h
Alternative to the above commandnpm install --help
scripts
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-server