Node learning-introduction to NPM

Getting started with NPM

NPM is a package management tool installed with NodeJS

Commonly used npm commands

View version information

npm -v // 查看版本信息

Local installation and global installation

npm install express  //本地安装
npm install express -g //全局安装

View all globally installed modules

npm list -g

View the version number of a certain module

npm list grunt

Uninstall the module

npm uninstall express

Update module

npm update express

Use nrm for package management

npm install -g nrm //全局安装 nrm
nrm ls // 列出所有可用的npm源
nrm use taobao // 使用淘宝npm源

Create and publish modules (open only for use on the npmjs official website)

npm init -y //初始化包模块
npm adduser // 添加用户
npm publish // 发布模块

version number

When using NPM to download and publish code, you will be exposed to the version number. NPM uses semantic version numbers to manage code, here is a brief introduction.
The semantic version number is divided into three digits XYZ, which represent the major version number, the minor version number, and the patch version number respectively. When the code changes, the version number is updated according to the following principles.

  • If you just fix the bug, you need to update the Z bit.
  • If only a new function is added, but it is backward compatible, the Y bit needs to be updated.
  • If there is a big change, it is downward incompatible, and the X bit needs to be updated.
    After the version number has this guarantee, in addition to relying on a fixed version number, it can also rely on a range of version numbers when declaring third-party package dependencies. E.g:

‘argv’:‘0.0.x’

Indicates that it depends on the latest version of argv of the 0.0.x series.

Guess you like

Origin blog.csdn.net/weixin_53985543/article/details/115011761