May-30, 2021 · 5min
change languageCollect and organize common commands for the npm package manager, including module installation and uninstallation, configuration management, mirror source settings, version control, and other practical techniques.
npm config listIt will generate a package.json file with the information of the current project
npm initView current mirror source
npm get registrySet to Taobao mirror source
npm config set registry http://registry.npm.taobao.org/Set back to the default official mirror
npm config set registry https://registry.npmjs.org/You can also install cnpm directly
npm install -g cnpm --registry=https://registry.npm.taobao.orgIt will create a node_modules directory
npm install <Module Name>Global installation
npm install <Module Name> --global
# or
npm install <Modele Name> -gInstall in the current directory's node_modules, and add the module information to the package.json's dependencies (production environment dependencies)
npm install <Module Name> --save
# or
npm install <Module Name> -SInstall in the current directory's node_modules, and add the module information to the package.json's devDependencies (development environment dependencies)
npm install <Module Name> --save-dev
# or
npm install <Module Name> -Dnpm uninstall <Module Name>npm search <Module Name># View version
npm -v
# Upgrade
npm install npm -gView current proxy
npm config get proxySet proxy
npm config set proxy=http://server:portIf the following error occurs
npm err! Error: connect ECONNREFUSED 127.0.0.1:8087Solution (clear proxy)
npm config set proxy nullView globally installed modules
npm list -gnpm update <Module Name>npm cache clear --force