LANG SELRCT

コードを書く場所

2019年7月22日月曜日

firebase-toolsのインストール時に出たcheckPermissions Missing write accessを解決したい


$ npm -g install firebase-tools

を実行したら

npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules

など以下のようなエラーが出ました



terminal
SatoshinoMacBook-ea:~ satoshikishimoto$ npm -g install firebase-tools
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!     /Users/satoshikishimoto/.npm/_logs/2019-07-22T12_53_22_601Z-debug.log



$ sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}

を実行して、再度

$ npm -g install firebase-tools

を実行すると

node-pre-gyp WARN Using request for node-pre-gyp https download

という以下のようなエラーが出ました



terminal
SatoshinoMacBook-ea:~ satoshikishimoto$ npm -g install firebase-tools
/usr/local/bin/firebase -> /usr/local/lib/node_modules/firebase-tools/lib/bin/firebase.js

> fsevents@1.2.9 install /usr/local/lib/node_modules/firebase-tools/node_modules/fsevents
> node install

node-pre-gyp WARN Using request for node-pre-gyp https download
[fsevents] Success: "/usr/local/lib/node_modules/firebase-tools/node_modules/fsevents/lib/binding/Release/node-v57-darwin-x64/fse.node" is installed via remote
+ firebase-tools@7.1.1
added 576 packages from 305 contributors in 28.639s

┌─────────────────────────────────────────────────────────────────────┐
│                       npm update check failed                       │
│                 Try running with sudo or get access                 │
│                to the local update config store via                 │
│ sudo chown -R $USER:$(id -gn $USER) /Users/satoshikishimoto/.config │
└─────────────────────────────────────────────────────────────────────┘



上記メッセージの最後に書かれている通り

$ sudo chown -R $USER:$(id -gn $USER) /Users/satoshikishimoto/.config

を実行してから、再度

$ npm -g install firebase-tools

を実行すると

terminal
SatoshinoMacBook-ea:~ satoshikishimoto$ sudo chown -R $USER:$(id -gn $USER) /Users/satoshikishimoto/.config
SatoshinoMacBook-ea:~ satoshikishimoto$ npm -g install firebase-tools
/usr/local/bin/firebase -> /usr/local/lib/node_modules/firebase-tools/lib/bin/firebase.js
+ firebase-tools@7.1.1
updated 1 package in 23.949s
SatoshinoMacBook-ea:~ satoshikishimoto$

インストールできました


参考

Firebase Web Codelab
https://codelabs.developers.google.com/codelabs/firebase-web/?hl=ja#3

npmでpermission deniedになった時の対処法[mac]
https://qiita.com/okohs/items/ced3c3de30af1035242d
(こちらの対策1で解決に至りました)