Ami
Ami

Reputation: 183

How to fix "zsh: command not found: vue"?

I installed @vue/cli on my mac, but whenever I type “vue”, my terminal says “zsh: command not found: vue” - How can I fix this problem? I searched similar issues and already spent half a day, but still not solved...

This is my environment:

I changed $PATH by doing this:

echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.zshrc

Now this is:

echo $PATH
/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Library/Apple/bin:/usr/local/share/dotnet:/opt/X11/bin:~/.dotnet/tools:/Library/Frameworks/Mono.framework/Versions/Current/Commands

It looks like @vue/cli is installed, but I don't know why vue command is not found. Don't I have an admin privilege?

~ % npm install -g @vue/cli
/Users/ami/.npm_global/bin/vue -> /Users/ami/.npm_global/lib/node_modules/@vue/cli/bin/vue.js
+ @vue/[email protected]
updated 1 package in 46.758s
~ % node -v
v10.13.0
~ % npm -v
6.4.1
~ % vue -v    
zsh: command not found: vue
~ % vue create new-project
zsh: command not found: vue

I'm following Vue CLI's instruction, so the result is supposed to be creating a new vue project. https://cli.vuejs.org


SOLVED Thank you for your advice! I tried ~ % export PATH=~/.npm_global/bin:$PATH and my path became:

~ % echo $PATH
/Users/ami/.npm_global/bin
:/usr/local/bin
:~/.npm_global/bin
:/usr/local/bin
:~/.npm_global/bin
:/usr/local/bin
:/usr/bin
:/bin
:/usr/sbin
:/sbin
:/Library/Apple/usr/bin
:/Library/Apple/bin
:/usr/local/share/dotnet
:/opt/X11/bin:~/.dotnet/tools
:/Library/Frameworks/Mono.framework/Versions/Current/Commands

And try again:

~ % vue --version
@vue/cli 4.0.5

Worked!

Upvotes: 18

Views: 24766

Answers (7)

Nitoh
Nitoh

Reputation: 1

I got stack with the same issue for 2 days but I finally got a solution for it

  1. Add the npm global packages directory to your PATH. Open your zsh configuration file (~/.zshrc) in a text editor (To open a text editor on mac terminal use command open -e ~/.zshrc )

  2. Then add the following line at the end of the file: export PATH=$PATH:$(npm config get prefix)/bin

  3. Then, source the .zshrc file to apply the changes:

source ~/.zshrc

Finally run vue --version

Upvotes: 0

Behnam Rakhshani
Behnam Rakhshani

Reputation: 563

the first you should remove all vue cli by enter 2 command

npm uninstall --global vue-cli
npm uninstall --global @vue/cli

then you should enter this commad for install the latest version of vue cli

npm install --global @vue/cli@latest

I tried this in mac os 10.15.4 and worked

and then I install

@vue/cli 4.4.6

good luck :)

Upvotes: 30

hljubic
hljubic

Reputation: 139

Open /etc/paths file with nano or some other editor as a superuser (sudo nano /etc/paths).

Add following line at the bottom

/usr/local/Cellar/node/15.2.1/bin

Before that, just check the node version (mine is 15.2.1).

Save changes, reboot your laptop and you're ready to go.

Upvotes: 0

Nafiz Bayrak
Nafiz Bayrak

Reputation: 200

if none of the above work

npm config set prefix /usr/local

and

npm install -g @vue/cli 

that's worked for me

Upvotes: 5

alejandrodotor8
alejandrodotor8

Reputation: 672

You have to change the .zhsrc in /Users/[username]/.zshrc and add:

export PATH=$PATH:/Users/[username]/.npm-global/bin

Check that your packages are in npm-global or npm-packages.

To see hidden file use cmd+shift+.

Upvotes: 6

atazmin
atazmin

Reputation: 5707

mac os catalina with zsh terminal

  1. Uninstalled node and npm using https://www.positronx.io/how-to-uninstall-node-js-and-npm-from-macos/
  2. Downloaded node/npm from https://nodejs.org/en/download/current/
  3. sudo npm install -g @vue/cli
  4. vue --version (@vue/cli 4.5.4)

Upvotes: 2

ctrl-alt-delete
ctrl-alt-delete

Reputation: 3862

I tried all of the above to no avail on Catalina 10.15.4

The fix is to

  1. uninstall Node and Npm
  2. go to Downloads Node.js and install the 64-bit version from Package
  3. sudo npm install --global vue-cli
  4. vue -V

2.9.6

Upvotes: 1

Related Questions