First, NPM Introduction:
NPM, called node Package Manager, is a node. JS-based pack manager and the most popular and supported third-party module in the entire node. JS community.
Usage Scenarios for NPM:
- Allows users to download third-party packages written by others from the NPM server for local use.
- Allows users to download and install command-line programs written by others from the NPM server for local use.
- Allows users to upload their own packages or command-line programs to the NPM server for others to use.
NPM version query: npm-v
NPM Installation:
1, installation Nodejs
Because NPM is already integrated with the new Nodejs, you can test for a successful installation by entering Npm-v directly.
2. Use NPM command to upgrade NPM:NPM install Npm-g
Second, the use of NPM
- Package Management:
- To install a module (package) using NPM:
Local Install command: NPM install <package name> Example: NPM Install Express
Global Install Command: NPM install <package name> Example: NPM install Express-g
Local Installation Method:
-
- Place the installation package under./node_module (the directory where the NPM command is running), and if there is no Node_modules directory, the Node_modules directory is generated under the directory where the NPM command is currently executing.
- Locally installed packages can be introduced via require ().
Global Installation Method:
-
- Place the installation package under/usr/local or your node's installation directory.
- Can be used directly on the command line.
If you want to have both features, you'll need to install it in two places or use NPM link.
Next we use the global way to install EXPRESS:NPM install Express-g
View all globally installed modules: NPM is-g
If the following error occurs:
NPM err! Error:connect econnrefused 127.0.0.1:8087
The workaround is: NPM config set proxy null
Local: NPM update <package name> For example: NPM Update Express
View update package commands: NPM outdated
Global: NPM install-g <package> For example: NPM Install-g Express
Update all packages: NPM update-g
Find update packages: NPM outdated-g--depth=0
Local: NPM Uninstall <package> For example:npm Uninstall Express
After uninstalling, you can check to see if the package still exists in the/node_modules/directory, or use the following command to view:
NPM is// NPM Uninstall--save Express
Global: NPM uninstall-g <package> For example: NPM Uninstall-g Express
-
- The release of the package:
To modify NPM permissions:
Ls-l View global permissions.
You may receive a global error if you try to install a global package for storage and use related commands without NPM permissions EACCES
.
You can use one of the following two options: solve this problem
- Change the default directory for license NPM.
- The default directory for NPM changes to another directory.
You should be ready to back up your computer before.
1. Modify the default directory of the license NPM.
To create a module:
Retrieving modules:
The configuration of NPM:
Iii. How NPM works:
Iv. NPM Team Building:
V. Using CLI commands:
Vi. Programming with NPM:
NPM's use with NPM's team building