LoginSignup
3
3

More than 3 years have passed since last update.

Vue-Cliのインストールに失敗して試したこと

Last updated at Posted at 2019-01-15

問題点

vue-cliをインストールしようと思ったら、以下のエラーが出てきました。


$ npm install -g @vue/cli
npm WARN deprecated cross-spawn-async@2.2.5: cross-spawn no longer requires a build toolchain, use it instead
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! path /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
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!   stack: '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! 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 (though this is not recommended).

npm ERR! A complete log of this run can be found in:
npm ERR!     /<各位のディレクトリ>

解決方法

npmのデフォルトディレクトリを以下コマンドで変更
npm config set prefix '~/.npm-packages'
この後もう一度npm install -g @vue/cliを行って、無事にインストール完了。

オプションの-gはグローバルを意味するため、これを実行するにはrootユーザーでないとエラーが出ます。
そのためsudoを使ってインストールするか、あるいは(モジュールがグローバルにインストールされたくない場合は)許可があるパスにnpm prefixを設定する必要があるわけですが、今回は後者を使いました。

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3