Mac uses nvm to manage multiple versions of nodes. The content covers a wide range of topics. Please view it on demand.
Homebrew installation
Homebrew is a software package management tool under the Mac OS platform. It has many practical functions such as installation, uninstallation, update, viewing, and search. With a simple command, package management can be implemented without you having to worry about various dependencies and file paths. It is very convenient and fast.
Enter the following code in the terminal to run
/bin/bash -c "$(curl -fsSL https://gitee.com/ineo6/homebrew-install/raw/master/install.sh)"
After entering the password, follow the prompts to complete the operation! After completion, enter the following code to check whether the installation is successful
brew -v
Outputting the version number indicates that the installation is successful!
nvm installation
nvm is a node version management tool. In order to solve the incompatibility of various node versions, nvm is a tool that allows you to install and switch different versions of node on the same machine.
Enter the following code in the terminal to run
brew install nvm
After the installation is successful, enter nvm -v to check whether the version number is output.
if not
- open -e ~/.bash_profile opens this file. If you do not directly touch ~/.bash_profile, create it and then open it.
export NVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.sh
- open -e ~/.zshrc opens this file. If you do not directly touch ~/.zshrc, create it and then open it.
export NVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.sh
- open -e ~/.profile opens this file. If you don’t directly touch ~/.profile, create it and then open it.
export NVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.sh
- Execute the following code in sequence to reload the file
source ~/.bash_profile
source ~/.zshrc
source ~/.profile
- Enter nvm -v again to see if the version number is output. The output of the version number indicates success!
node.js installation
- Install the specified version of node.js: nvm install version number ( check the official website for the version number )
- Check the local node.js version: nvm list
- Switch to the specified version: nvm use version number (local node.js version)
- Set the default version of node.js. This version will be used every time you start the terminal: nvm alias default version number (local node.js version)
- Uninstall the specified node.js version: nvm uninstall version number (local node.js version)
- Install the latest stable version of node.js: nvm install --lts
- View all versions of node.js: nvm ls-remote
- Use node.js to specify the version to execute the file: nvm exec version number node file path to be executed
npm Taobao mirror configuration
As we all know, accessing foreign websites is very slow, so it is necessary to configure domestic mirrors
- npm get registry View the original image
- npm config set registry http://registry.npm.taobao.org/ modified to Taobao mirror
- npm config set registry https://registry.npmjs.org/ Image restoration