JavaScript Building a MEAN Application Setting Up MongoDB Debugging Express Application Refresher

Peter Vann
Peter Vann
15,695 Points

Can't get iron-node to install on Ubuntu 16.04

Can someone help me get iron-node installed on Ubuntu 16.04?

After running:

sudo npm install iron-node -g

I get this error message:

/usr/bin/iron-node -> /usr/lib/node_modules/iron-node/bin/run.js

electron@1.7.6 postinstall /usr/lib/node_modules/iron-node/node_modules/electron node install.js

/usr/lib/node_modules/iron-node/node_modules/electron/install.js:48 throw err ^

Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/iron-node/node_modules/electron/dist' npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! electron@1.7.6 postinstall: node install.js npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the electron@1.7.6 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/pepe/.npm/_logs/2017-09-22T22_54_21_950Z-debug.log

I installed electron trying to solve the problem, but it didn't help.

In trying to figure this out I noticed that the directory '/usr/lib/node_modules/iron-node/' was not created.

Thank you for any/all help.


1 Answer

Peter Vann
Peter Vann
15,695 Points

Actually - found my own solution here:

================================================= Option 2: Change npm's default directory to another directory

There are times when you do not want to change ownership of the default directory that npm uses (i.e. /usr) as this could cause some problems, for example if you are sharing the system with other users.

Instead, you can configure npm to use a different directory altogether. In our case, this will be a hidden directory in our home folder.

Make a directory for global installations: mkdir ~/.npm-global

Configure npm to use the new directory path: npm config set prefix '~/.npm-global'

Open or create a ~/.profile file and add this line: export PATH=~/.npm-global/bin:$PATH

Back on the command line, update your system variables: source ~/.profile

Test: Download a package globally without using sudo.

npm install -g iron-node


It worked. Iron-node finally installed without errors.

It apparently was a permissions issue. The error messaging doesn't always make the problem obvious.

I hope this helps someone else that might encounter this problem.