格 千格 KiloCell

NPM command quick check

Node Package Manager Common Commands Collection

What's NPM?

NPM (Node Package Manager) is the default package manager for Node.js and the largest open-source reservoir ecosystem in the world. Pass. NPM, developer can easily install, share and distribute codes and manage dependency in projects.

Why use NPM command speed check?

Although most developers use it every day, npm install or npm start But NPM also provides a lot of powerful orders that are not often remembered (e.g. npm audit , npm link or npm outdated )。

  • Efficiency improvements: Quick find an unusual command without having to look through a lengthy official document.
  • Addressing specific issues: For example, how to use a project when there is a security gap npm audit fix Auto fix.
  • Normative development: Learn how to use it right -D The markers distinguish between development and production dependence.

NPM Common Command Detail

1. Initialization of projects

Use npm init Start a new project. If you want to skip all questions and use the default value, use npm init -y 。 It'll create one immediately. package.json Documentation.

2. Dependence on management

The installation package is the NPM's most core function. npm install <package> Add Package to dependencies medium, and npm install -D <package> Add it to devDependencies (Tools used only in the development environment, e. g. Webpack or ESLint).

3. Run scripts

npm run <script-name> Allows you to execute package.json middle scripts . Any command defined in the object. - It's common. build , lint , dev Wait.

4. Configuration and mirroring

In the domestic development environment, direct access to official NPM warehouses may be slow due to network reasons. Pass. npm config set registry The command switch to the ngmmirror can significantly increase download speed.

Specific issues addressed

This tool aims to address the following development pains:

  • Can't remember complex instructions: Like looking at the global package. npm list -g --depth=0 。
  • Security awareness-raising: Quick query how to scan the holes and auto-recover them.
  • Environmental coherence: Pass. npm ci (Clean Install) Ensures that the user versions are fully consistent with the team members' installation.
Copyed to clipboard