Error when trying to install react-devtools

Viewed 4333

I am trying to install react-devtools with this code

sudo npm install -g react-devtools

after running this command, I am getting this error.

/usr/local/bin/react-devtools -> /usr/local/lib/node_modules/react-devtools/bin.js

> electron@1.6.11 postinstall /usr/local/lib/node_modules/react-devtools/node_modules/electron
> node install.js

/usr/local/lib/node_modules/react-devtools/node_modules/electron/install.js:47
  throw err
  ^

Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/react-devtools/node_modules/electron/.electron'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! electron@1.6.11 postinstall: `node install.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the electron@1.6.11 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/jayakrishnan/.npm/_logs/2017-08-07T11_22_05_742Z-debug.log

How can I correct this? I am desperately in need of devtools for debugging. If possible, please suggest better debugging tools for React Native.

4 Answers

Based on this issue try the following command to fix this issue:

sudo npm install -g react-devtools --unsafe-perm=true

allow-root option doe's not solving this issue.

I solved this issue by using yarn.

brew install yarn
yarn global add react-devtools

You don't need to change permissions this way.

use this command it will solve your error:

sudo npm install -g electron --unsafe-perm=true --allow-root

I have been resolved in Ubuntu 18.04 by

sudo chmod 777 /usr/lib/node_modules

sudo npm install -g --verbose react-devtools@4

Related