mac终端通过vue ui命令启动可视化界面不生效

背景:mac电脑,终端输入vue ui 没效果

刚开始在网上找通过vue ui创建项目的方法,看到要安装vue cli,-g意思是全局安装,命令为

npm install -g @vue/cli

我复制到终端运行,结果报错,报错为:

hfzhang@hfzhangdeMacBook-Pro ~ % npm install -g @vue/cli
npm WARN deprecated subscriptions-transport-ws@0.11.0: The `subscriptions-transport-ws` package is no longer maintained. We recommend you use `graphql-ws` instead. For help migrating Apollo software to `graphql-ws`, see https://www.apollographql.com/docs/apollo-server/data/subscriptions/#switching-from-subscriptions-transport-ws    For general help using `graphql-ws`, see https://github.com/enisdenjo/graphql-ws/blob/master/README.md
npm WARN deprecated source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib/node_modules
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR!  [Error: EACCES: permission denied, access '/usr/local/lib/node_modules'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/local/lib/node_modules'
npm ERR! }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/hfzhang/.npm/_logs/2022-10-10T06_31_54_522Z-debug.log

根据报错信息,

permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator. 
文件及其包含的目录的权限,或尝试运行npm犯错!再次以root/管理员的身份执行该命令。

报错可能是因为没有获取管理员权限,所以我再次使用了以下命令

sudo npm install -g @vue/cli

mac电脑在使用sudo时需要输入密码

运行结果还是报错,报错结果同上。

我开始在网上流浪,找到了一种方法解决,亲测有效。

是因为vue的版本问题,需要先卸载原来的vue,然后安装新的版本的vue。

卸载命令:

npm uninstall vue-cli -g

卸载不了的话需要使用sudo命令:

sudo npm uninstall vue-cli -g

卸载之后安装新版本:

sudo npm insatll @vue/cli -g

安装好之后在输入:

vue ui

就能够正常启动可视化界面了,具体的项目创建操作请参照vue ui创建和管理项目

如果已经安装了vue cli,然后vue ui起不来可视化界面的建议直接卸载,卸载之后再安装。

如果未安装vue cli,建议先安装,安装的时候最好使用sudo命令,可以省点时间,不会出现权限报错。

这些都是亲测的,真实有效,再次强调,本人使用的mac电脑,windows未知哦,大家可以试一试。

欢迎大家评论留言!

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值