NodeJS

Fix error when install npm package as global package

Today, I will guide you to fix error when install npm package as global package.
I ran below command to install npm package as global package but installation was failed.
Command: sudo npm install -g electron
Error will look like:
Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/electron/.electron'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `node install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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/ubuntu/.npm/_logs/2018-03-18T10_25_47_793Z-debug.log

And this option saved my time:
--unsafe-perm=true --allow-root

I hope this post is helpful.