Mac OS : Install vue cli does work properly

一世执手 提交于 2019-12-06 05:31:20

问题


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/cli@3.0.0-rc.3 


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?


回答1:


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.




回答2:


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




回答3:


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.



回答4:


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



来源:https://stackoverflow.com/questions/51005638/mac-os-install-vue-cli-does-work-properly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!