zsh on Mac OS: command not found: vue problem solution

Problem Description

使用vue命令出现错误

Installation steps of the vue command:

  • npm install yarn -g : install yarn
  • yarn global add @vue/cli : use this command to install vue scaffolding
  • vue create project name: use this command to create a project

After inputting according to the above steps, the vue scaffolding is successfully installed, but an error is reported zsh: command not found: vue, resulting in the failure of project creation


Cause Analysis:

The execution command cannot be found, and the location of the installation package needs to be told to the system

The yarn command is installed under .yarn/bin by default
Enter the following command to view the yarn installation package

 ls ~/.yarn/bin

insert image description here

Enter the following command to find the installation location of yarn

cd ~/.yarn/bin
pwd

![Insert picture description here](https://img-blog.csdnimg.cn/fc932bcee6aa4324b80b014dcbebc852.png = 200*30)


solution:

Modify the .bash_profile or .zshrc file

Since I have modified .bash_profilethe content when I installed yarn, I found that the vue command still cannot be found, so I am modifying it here.zshrc

vim ~/.zshrc

.zshrcAdd the following command on the last line of :

export PATH="/Users/[用户名]/.yarn/bin:$PATH"

After using :wqsave, enter the following command

source ~/.bash_profile

Enter again at this time

vue -v

insert image description here
If the above content appears, it means success!

Guess you like

Origin blog.csdn.net/hjw15910531612/article/details/126752884