2. npm

https://www.npmjs.com/

Check environment:

$ npm doctor

Upgrate npm:

$ npm install -g npm

Note

Because our npm is installed in current user’s home directory by nvm (along with node), no root previlege is needed.

Clear cache:

$ npm cache clear --force

Install packages in current directory:

$ npm install

List packages installed:

$ npm ls

List packages outdated:

$ npm outdated

Install latest version of a package:

$ npm install react@latest

Uninstall a package:

$ npm uninstall @rjsf/core --force

Show configurations:

npm config get
; node bin location = /Users/xxxx/.nvm/versions/node/v23.11.0/bin/node
; node version = v23.11.0
; npm local prefix = /Users/xxxx/workspace/homepage/lasys
; npm version = 11.3.0

Set registry mirror:

$ npm config set registry https://mirrors.cloud.tencent.com/npm/

The configuration is saved in ~/.npmrc.

registry=https://mirrors.cloud.tencent.com/npm/