无法安装Vue CLI? (苹果系统)

时间:2020-06-21 05:58:26

标签: node.js vue.js npm terminal vuejs2

嘿,所以我试图通过npm(sudo npm install -g @vue/cli)安装Vue,但我只收到一堆警告和错误,我无法真正理解它,也不知道为什么会发生。

npm WARN deprecated request@2.88.2: request has been deprecated, see [`https://github.com/request/request/issues/3142`](https://github.com/request/request/issues/3142)
npm WARN deprecated resolve-url@0.2.1: [`https://github.com/lydell/resolve-url#deprecated`](https://github.com/lydell/resolve-url#deprecated)
npm WARN deprecated urix@0.1.0: Please see [`https://github.com/lydell/urix#deprecated`](https://github.com/lydell/urix#deprecated)
npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.

/usr/local/bin/vue -> /usr/local/lib/node_modules/@vue/cli/bin/vue.js
> fsevents@1.2.13 install /usr/local/lib/node_modules/@vue/cli/node_modules/fsevents`
> node install.js
gyp WARN EACCES current user ("nobody") does not have permission to access the dev dir "/Users/jamesecroyd/Library/Caches/node-gyp/12.18.0"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/@vue/cli/node_modules/fsevents/.node-gyp"
gyp WARN install got an error, rolling back install
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/@vue/cli/node_modules/fsevents/.node-gyp'
gyp ERR! System Darwin 18.7.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/@vue/cli/node_modules/fsevents
gyp ERR! node -v v12.18.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok

任何人都知道为什么会这样吗? 我已经多次安装和卸载了Vue,没有运气...

3 个答案:

答案 0 :(得分:3)

使用NPM的--unsafe-perm标志:

sudo npm install -g @vue/cli --unsafe-perm

或切换到节点版本管理器(例如nvmn),这样可以避免这些问题。

答案 1 :(得分:1)

通过以下方式修复了我的Mac安装:

  1. 先卸载vue cli。

sudo npm uninstall -g @vue/cli

  1. 重新安装了添加的开关,以处理文件访问问题。给出一些警告,但没有错误。

sudo npm install -g @vue/cli --unsafe-perm

  1. 然后,将依赖性安装在警告中,该警告在步骤2的安装结束时显示。

sudo npm install -g vue@3.0.0-rc.9

在第3步之后,“ vue --version”命令此时会打印“ @ vue / cli 4.5.4”,但以前会这样做。

因此,为了进行真正的测试,我在vue ui中创建了一个新项目,该过程比原始的第一个麻烦的vue cli安装后创建的最初的第一个项目要花费更长的时间(超过30秒)。

并且新项目有效! –我在“任务”窗口中单击“保留”,可以在“输出”窗口中看到干净的构建,并且演示页面如http://localhost:8080/一样加载它应该!欢迎使用您的Vue.js应用等...

答案 2 :(得分:0)

我遇到了同样的问题 只需运行此命令

<块引用>

sudo npm uninstall -g @vue/cli

首先检查你是否安装了 npm 和 node