This article has participated in the Denver Nuggets Creators Camp 3 “More Productive writing” track, see details: Digg project | creators Camp 3 ongoing, “write” personal impact.
Nice to see you again! 😊
NPM stands for Node Package Manager and is one of the most commonly used tools by many developers. It puts all modules in one place so Node can find them and manage dependency conflicts. The following is a list of the most common NPM commands you should know as a developer.
❤️ As a developer you need to know about the NPM command ❤️
🎁 install
This command is used to install the NPM package and other packages that a particular package depends on. It will be installed in the local node_modules folder.
npm install <packagename>
Copy the code
There is a shorthand for installing a new package: 👇
npm i <packagename>
Copy the code
👓 uninstall
This command is the exact opposite of installation. It will completely uninstall packages that already exist in the node_modules folder. If the package mentions that there is no package.json list or node_modules folder, it doesn’t do anything.
npm uninstall <packagename>
Copy the code
Short for uninstalling the new software package 👇
npm un <packagename>
Copy the code
🎓 update
This command updates the current package to the latest version, or all packages if a package name is not specified. If certain packages are missing, it also checks and updates them.
npm update <packagename>
Copy the code
Or 👇
npm update
Copy the code
Short for update package 👇
npm up <packagename>
Copy the code
🍰 deprecate
This command updates the package’s NPM registry key by providing deprecation warnings or messages to all who try to install it.
npm deprecate <pkg>[@<version range>] <message>
Copy the code
== Note == : To undeprecate specific packages, specify an empty string (“”) for the message parameter. Note that you must use double quotes, with no Spaces between them.
npm deprecate <pkg>[@<version range>] ""
Copy the code
🧁 doctor (check)
This command checks our environment so that our NPM installation has what it needs to manage our JavaScript package. Before installing NPM, you will check some basic requirements that the package must meet.
- Node.js and Git must be executable by NPM.
- Ensure that the NPM registry, registry.npmjs.com or other services that use the registry API are available.
- Directories using NPM, node_modules (local and global) exist and can be written by the current user.
npm doctor
Copy the code
🍺 list
This command prints all installed packages and their versions, along with their dependencies in the tree structure.
npm list
Copy the code
🥇 view
This command prints data about the package.
npm view <packagename> <versions>
Copy the code
If the version is not specified, the default version is the latest
🎯 help
This command helps with the topic above. It displays the corresponding document page.
If the topic does not exist, or if more than one term is provided, NPM will run thishelp-search
Command to find a match. ifhelp-search
Finds a single topic, then it runs help for that topic, so a unique match is equivalent to specifying the topic name.
npm help <term>
Copy the code
🎢 Global installation/update package
This command installs or updates packages globally on the local system.
npm install -g nodemon
npm update -g nodemon
Copy the code
-g Specifies the global. If -g is not specified, the package is installed locally by default and cannot be accessed outside the project directory.
🎪 Install software packages as production/development dependencies
This command installs the packages available in the specified environment.
'NPM install -p <packagename>' P for production. 'NPM install -d <packagename>' D for developmentCopy the code
🎡 init (initialization)
The command can be added by adding itpackage.json
The file converts an empty directory into an NPM project.
In addition, you canpackage.json
The meta information for the project is added to the file when it is created.
If you arepackage.json
Not in the catalog, andnpm install moduleName
Triggered at the directory path, the module will be installed globally.
npm init
Copy the code
or
npm init -y
Copy the code
🏀 build
npm build
andnpm run build
Totally different.
npm run build
— This command runs the build field from package.json script field.
npm build
This is an internal order. If you run it, you get:npm WARN build npm build called without arguments.
🎏 start
Run this commandpackage.json
Predefined commands specified in the start property available within the script in the file.
npm start
Copy the code
✨ stop (End)
Run this commandpackage.json
Predefined commands specified in the Stop property available within scripts in the file. Unlike start, if the stop attribute is not defined, no default script will be run
npm stop <filename>
Copy the code
❤️ is written at the end ❤️
That’s all for this article
💌 welcomes your comments and suggestions in the comments section! 💌
If you really learn something new from this article, like it, bookmark it and share it with your friends. 🤗 and finally, don’t forget ❤ or 📑.