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

jec*_*918 2 terminal node.js npm vue.js 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
Run Code Online (Sandbox Code Playgroud)

任何人都知道为什么会发生这种情况?我已经安装和卸载了Vue多次,但没有成功......

ton*_*y19 5

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

sudo npm install -g @vue/cli --unsafe-perm
Run Code Online (Sandbox Code Playgroud)

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