macos -bash: yarn: command not found/-bash: cnpm: command not found

-Bash: cnpm: command not found
– bash: Yarn: command not found
– bash: XXXX: command not found
all yarn/cnpm above are common, provided that this error is reported after successful installation

error: eacces: permission denied, MKDIR please move on to this article 👉 https://www.cnblogs.com/niceyoo/p/11703560.html

Different from windows , we use sudo NPM install – G yarn to install yarn , but we report the following error information when printing the terminal version or using yarn directly:

-bash:yarn:commandnotfound

One of the reasons is that the environment variables similar to those in windows are not configured

Input at the terminal:

open-e~/.bash_profile

The above command mode will be directly edited in Notepad or VIM command in console

vim~/.bash_profile

If you use the method of VIM to modify, remember to execute : WQ to save and exit


Taking the Open instruction as an example, we execute the following instructions on the terminal:

1、touch ~/.bash_ profile

Can skip, touch means to create without. Bash_ Profile is a temporary environment variable of the system

2、open -e ~/.bash_ profile

Open command to open this file. If you are prompted that you have no permission, please add sudo before it. Example: sudo open – E ~ /. Bash_ profile

3. Find the installed yarn directory 2

Do you remember the directory where you installed yarn?If you forget to perform the installation again, as shown in the figure below (the picture is the non self coding on the Internet)

4_ In the profile file, enter export path = $path/usr/local/node_ global/bin

Note: please set /usr/local/node_ Global replace with the directory where your yarn exists

5、source ~/.bash_ profile

Source means to re execute or refresh

6、yarn -v


official account was buddy Java, which I created a Java related public number. I can record my own learning path. Interested partners can pay attention to the official account of the public: Ha: niceyoo

Similar Posts: