Install NodeJS
Government area:https://nodejs.org/zh-cn
After the installation is complete, open the terminal
node -v
When installing NodeJS, the npm package management tool will be automatically integrated, and you can use npm normally;
Installation and use of nvm
Official address:nvm Documentation Manual - nvm is a nodejs version management tool - nvm Chinese website
Installation tutorial:nvm installation, nvm adjustment of node version addition, deletion, checking and modification - Nuggets
Use nvm
nvm list
nvm related commands
nvm -h //View nvm instructions nvm list //View the locally installed node version list nvm list available //View node versions that can be installed nvm install latest //Install the latest version of node nvm install [version][arch] //Install the specified version of node. For example: nvm install 10.16.3 to install node v10.16.3 arch represents the number of digits of the computer. If the computer needs to install 32-bit, run: nvm install 10.16.3 32 nvm use [version] //Use node For example: nvm use 10.16.3 nvm uninstall [version] //Uninstall node
npm related commands
//Install all packages npm i //Global installation package npm i -g package name //Install the specified version of the package npm i package name@version number //Install the latest package name npm i package name@latest //Update npm npm i -g npm //Uninstall package npm uninstall package name
Installation and use of yarn
Install yarn
npm i yarn -g //Check whether the installation is successful yarn -v
Use of yarn
//Installation package // The latest version will be automatically installed and the specified version of the package will be overwritten yarn add <package_name> //Install the specified version of the package yarn add <package_name>@version number //Install multiple packages at once (separate packages with spaces) yarn add <package_name> <package_name> <package_name> //If you do not specify a dependency type, it will be installed in dependencies by default. You can also specify the dependency type: yarn add <package_name> --dev / -D // Add to devDependencies yarn add <package_name> --peer / -P // Add to peerDependencies yarn add <package_name> --optional / -O // Add to optionalDependencies //Install all packages yarn //Update package yarn upgrade <package_name> // Update to the latest version yarn upgrade <package_name>@version number // Update to the specified version // Remove package yarn remove <package_name> // Query the currently set image yarn config get registry //Switch Taobao mirror yarn config set registry https://registry.npm.taobao.org
Installation and use of pnpm
Install pnpm
above sea level and above sea level -g
Common commands of pnpm
//Install all packages pnpm install //Install a certain package pnpm add axios //Install into the specified environment pnpm add webpack -D //Run the project pnpm dev