Detailed instructions common npm

Common commands npm

First, I give you about npm site so that everyone in the learning process can be watching the official website while studying.
https://www.npmjs.com/ official website
https://www.npmjs.com.cn/ Chinese documents

Learn npm

npm is accompanied NodeJS package management tools installed together, can solve many problems on NodeJS deployed code, common usage scenarios are the following:

  • Allows users to download from the server written by someone else npm third-party packages to local use.
  • It allows users to download and install the command-line program written by someone else from using npm to the local server.
  • It allows users to write their own bag or command line program NPM uploaded to the server for others to use.

Common commands npm

Speaking npm instructions, we can look at the official website, I will not explain too much, and here was simply to tell you about our daily work in common development.

  1. npm install the package name     download package project
  2. npm install the package name @ version number     to download the specified version of the project package
  3. npm init     boot package to create a project file package.json
  4. npm uninstall package name     deleted (uninstalled) package project
  5. npm install     the default read package.json current folder

Here I give you one by one to explain the use of these instructions.
npm install the package name   (abbreviated npm i package name), is to download and install the program package, jQuery show you install this item package.
Here Insert Picture Description
Effect:
Here Insert Picture Description
In this way, we completed the download jQuery project package in the folder.

npm install the package name @ version number   (abbreviated npm i package name @ version number), show you download jQuery1.12.4 version.
Step above, results as follows:
Here Insert Picture Description
As shown, this version jQuery1.12.4 we put down to the installer.

the init npm     (abbreviated npm init -y), a guide to create package.json file in the project package.
Here Insert Picture Description
Here you will find when you finish execution npm init command, did not appear in the file package.json we expected, then we have to continue the instruction is completed, the name of our project and so lost inside.

Here Insert Picture Description
As shown, I want to fill about content to box out, fill in the name based on the needs on the line, it must be noted that the project name got to be English , remember the last input yes (OK).
Here Insert Picture Description
So we need package.json folder came out, in this folder which we can see what we project package download.

npm uninstall package name     to delete (uninstall) program package. First we have to understand that we have to download the project package before they can unload, can not uninstall empty project package. So I was ready first two projects package. Here we need to remove that jQuery project package.
Here Insert Picture Description
Finally, we retained only swiper that a project package.
Here Insert Picture Description

install npm     (abbreviated npm i), the default read package.json the current folder, all third-party which will record a one-time download. I put all files in the project of npm instructions inside are deleted.
Here Insert Picture Description
Finally, the implementation of our npm install command, you can put recorded in package.json inside the packages are downloaded from the project.

Here Insert Picture Description

Npm grasp and understand the above operation command, you can basically simple operation npm up.

At home against the war, fearless epidemic, refueling Wuhan, China refueling, humans win! ! !

Instructor: Guo Xiang

Published 11 original articles · won praise 3 · Views 293

Guess you like

Origin blog.csdn.net/qq_43942185/article/details/104486494