5
votes

I installed vue-cli running the following command:

npm install -g @vue/cli
/Users/me/npm/bin/vue -> /Users/me/npm/lib/node_modules/@vue/cli/bin/vue.js
/Users/me/npm/lib
└── @vue/[email protected] 


When I run vue init, get an the error: "command not found":

vue init webpack vue-app
-bash: vue: command not found

vue-cli does not seem to be in my PATH. When I check the PATH, it includes the directory /Users/me/npm/lib. Here is the result of echo $PATH

/usr/local/git/bin:/Users/me/npm/bin/ng:/Users/me/npm/lib:/usr/bin/local/bin:/Users/me/.rbenv/shims:/Users/me/.rbenv/shims:/usr/local/git/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/ImageMagick/bin:/Users/me/Tools/apache-maven-3.2.5/bin


What am I missing?

7
Did you try running the install command with sudo?Derek Pollard
I can't reproduce the problem on my MacBook Pro (macOS High Sierra, Node 10.4.1, vue-cli 3.0.0-rc.3). I'm using n though.tony19
your PATH does't include /Users/me/npm/bin, is /Users/me/npm/bin/ngjoaner

7 Answers

3
votes

You could try adding this to your $PATH:

/Users/me/npm/bin

Your $PATH currently goes one level deeper than this, in which case wouldn’t see the content of bin.

3
votes

The same issue occurred for me when running:

npm install -g @vue/cli

After much research and experimentation the only thing that worked instead was:

npm install -g @vue/cli@latest

2
votes

i had a sort a like issue on my mac, my problem was that i already had an old version installed, here are the stips i did to make it work:

  1. goto folder: /usr/local/lib/node_modules/ (in finder, choose go and then folder)
  2. move folders @vue and vue-cli to trash
  3. sudo npm install @vue/cli -g
  4. enter you admin password

works like charm

2
votes

For me worked this steps:

  1. Find the directory path to where vue-cli was installed. Mine was located here [replace username with yours] /Users/username/.npm-packages/bin
  2. Open up your bash profile: sudo nano ~/.bash_profile
  3. Add the following: export PATH=$PATH:/Users/[username]/.npm-packages/bin replacing [username] with your username.
  4. Save the file and restart terminal.
  5. You can now use vue in terminal as expected.
1
votes

For Mojave, after much struggling, I copied the installed path for @vue/cli

  1. Path [during installation path is shown]

    /Users/{your_username}/
    
    .npm-global/bin
    
  2. Open the GUI with:

    sudo nano ~/.bash_profile
    
    enter your password
    
  3. Paste the copied path as

    export PATH=$PATH:/Users/{your_username}/ .npm-global/bin
    
  4. Run:

    vue --version
    
0
votes

have you tried yarn? try to install yarn and run yarn global add @vue/cli for me it worked

0
votes

If you still have same problem and not only with vue cli, but any packages that must be installed globaly by NPM. For me helped:

brew uninstall node

And load Node.js as .dmg from official web-site https://nodejs.org/en/download/ and install from it.

After did sudo npm install -g @vue/cli and all worked.