やりたいこと
vue-cliをmacに入れたい。
問題
npm install -g @vue/cli
と打ったり、
```
sudo npm install -g @vue/cli
と打ったりしても、こんな感じのエラーが出てうまくインストールできない。
/usr/local/bin/vue -> /usr/local/lib/node_modules/@vue/cli/bin/vue.js
> fsevents@1.2.9 install /usr/local/lib/node_modules/@vue/cli/node_modules/fsevents
> node install
node-pre-gyp WARN Using request for node-pre-gyp https download
node-pre-gyp WARN Pre-built binaries not installable for fsevents@1.2.9 and node@8.12.0 (node-v57 ABI, unknown) (falling back to source compile with node-gyp)
node-pre-gyp WARN Hit error EACCES: permission denied, mkdir '/usr/local/lib/node_modules/@vue/cli/node_modules/fsevents/lib'
gyp ERR! configure error
gyp ERR! stack Error: Command failed: /Users/keisuke/.pyenv/shims/python -c import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack File "<string>", line 1
gyp ERR! stack import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack
gyp ERR! stack at ChildProcess.exithandler (child_process.js:276:12)
gyp ERR! stack at emitTwo (events.js:126:13)
gyp ERR! stack at ChildProcess.emit (events.js:214:7)
gyp ERR! stack at maybeClose (internal/child_process.js:915:16)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
gyp ERR! System Darwin 18.6.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/usr/local/lib/node_modules/@vue/cli/node_modules/fsevents/lib/binding/Release/node-v57-darwin-x64/fse.node" "--module_name=fse" "--module_path=/usr/local/lib/node_modules/@vue/cli/node_modules/fsevents/lib/binding/Release/node-v57-darwin-x64" "--napi_version=3" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v57"
gyp ERR! cwd /usr/local/lib/node_modules/@vue/cli/node_modules/fsevents
解決策
Errors during install of vue-cli on Mac OSX
を参考に
sudo npm install -g @vue/cli --unsafe-perm
と叩いたらいけた☆
結果
/usr/local/bin/vue -> /usr/local/lib/node_modules/@vue/cli/bin/vue.js
> fsevents@1.2.9 install /usr/local/lib/node_modules/@vue/cli/node_modules/fsevents
> node install
node-pre-gyp WARN Using request for node-pre-gyp https download
[fsevents] Success: "/usr/local/lib/node_modules/@vue/cli/node_modules/fsevents/lib/binding/Release/node-v57-darwin-x64/fse.node" is installed via remote
+ @vue/cli@3.8.4
added 68 packages from 33 contributors and updated 1 package in 51.369s
いぇい!