1、查看版本号
C:\Users\Administrator> npm -v 9.5.1
2、配置淘宝源
C:\Users\Administrator> npm install -g cnpm --registry=https://registry.npm.taobao.org npm WARN deprecated @npmcli/move-file@2.0.1: This functionality has been moved to @npmcli/fs added 470 packages in 24s 27 packages are looking for funding run `npm fund` for details
3、本地安装,会安装到当前项目
C:\Users\Administrator> npm install express added 58 packages in 5s 8 packages are looking for funding run `npm fund` for details
全局安装,会安装到指定的目录 (node_global)
C:\Users\Administrator> npm install express -g added 58 packages in 1s 8 packages are looking for funding run `npm fund` for details
安装指定版本
C:\Users\Administrator> npm install --save express@4.17.2 removed 8 packages, changed 14 packages, and audited 51 packages in 4s 2 packages are looking for funding run `npm fund` for details ...
4、查看 npm 安装的全局目录在哪里
C:\Users\Administrator> npm root -g C:\Users\Administrator\AppData\Roaming\npm\node_modules
5、查看 npm 配置信息
C:\Users\Administrator> npm config list ; "builtin" config from D:\ProgramFiles\nodejs\node_modules\npm\npmrc prefix = "C:\\Users\\Administrator\\AppData\\Roaming\\npm" ; node bin location = D:\ProgramFiles\nodejs\node.exe ; node version = v18.16.0 ; npm local prefix = C:\Users\Administrator ; npm version = 9.5.1 ; cwd = C:\Users\Administrator ; HOME = C:\Users\Administrator ; Run `npm config ls -l` to show all defaults.
查看完整的配置信息,请使用 npm config ls -l 命令。