Problem

sudo npm isntall -g PACKAGE
Error: EACCES: permission denied, mkdir '/usr/local/lib/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! /root/.npm/_logs/2017-06-17T04_24_22_944Z-debug.log

Solution

sudo npm install -g PACKAGE --unsafe-perm=true

from docs.npmjs.com:

unsafe-perm

    Default: false if running as root, true otherwise
    Type: Boolean

Set to true to suppress the UID/GID switching when running package scripts.
If set explicitly to false, then installing as a non-root user will fail.

References

  • https://docs.npmjs.com/misc/config#unsafe-perm
  • https://github.com/npm/npm/issues/17268