# Generate and answer yell to all
π npm init --yes
# Short hand
π npm init -y
2. Install Package
# install a package local to current folder
πnpm i <packageName>
# install a package with specific version
πnpm i <packageName>@<version>
# install a package globally
πnpm i -g <packageName>
3. Update Package
# update all production packages in current folder
π npm update
# update a specific package
π npm i <packageName>
# update a package globally
π npm update -g <packageName>
4. List Package
# list all packages in the current directory
π npm list
# short hand
π npm ls
# list packages installed globally
π npm list -g
# list packages in dev dependencies
π npm list --dev
# list packages in production
π npm list --prod
5. Check Security Issues
# scan your project for security issues
π npm audit
# get report in json format
π npm audit --json
# scan issues and fix them
πnpm audit fix
# if you want to skip dev dependencies
π npm audit fix --only=prod
6. Remove Extraneous Packages
π npm prune
When you run prune, the npm CLI will run through your package.json and compare it to your project's/node_modules directory. It will print a list of modules that aren't in your package.json.
Continue....
The npm prune command then strips out those packages, and removes any you haven't manually added to package.json or that were npm installed without using the --
7. Lock Dependency Versions
π npm shrinkwrap
using shrinkwrap in your project, generates an npm-shrinkwrap.json file. This allows you to pin the dependencies of your project to the specific version you're currently using within your node_modules directory.
Continue...
When you run npm install and there is a npm-shrinkwrap.json present, it will override the listed dependencies and any semver ranges in package.json
Thread Ended.
Let me know if you found it usefull π
β’ β’ β’
Missing some Tweet in this thread? You can try to
force a refresh