After configuring several times and repeatedly uninstalling but the uninstallation was not clean, I synthesized several articles and made a summary
1. Download Node.js
I have been downloading pkg before, but it will cause a lot of trouble, it will create folders in places you don't know, which will cause unnecessary trouble later, so now I choose to download the compressed package directly
Choose a directory for installation
2. Configure environment variables
The environment variables of Mac are a bit complicated, and they are the same as those of Linux. After I researched it myself, I configured it like this
1. Find the configuration file
2. Directly double-click to open to modify
3. Configure node_global and node_cache
Create two folders under the nodejs installation directory, named: node_global and node_cache
Configure these two folders
npm config set prefix "/Library/NodeJS/node-v16.17.0-darwin-arm64/node_global"
npm config set cache "/Library/NodeJS/node-v16.17.0-darwin-arm64/node_cache"
(Note the quotes!!!!)
These two commands to check
npm config get cache
npm config get prefix
4. Add the installation path to PATH
Regarding the error after installing yarn vue, etc.: yarn command not found
The problem is that after yarn is installed, its path does not exist in PATH (vue is the same), so you need to configure the path again
This problem has bothered me for a very long time! ! !
Configure the installation path of yarn
yarn config set global-folder “/.../node_global/bin/yarn_global”
yarn config set cache-folder “/.../node_global/bin/yarn_cache”
yarn config list
yarn global dir