Jeet Kalariya Jeet Kalariya - 3 months ago 23
Node.js Question

coffee-script is not installing on amazon ec2

I am using mac terminal to access my amazon ec2 free tier. I installed node and npm using commands.

but when I tried to install Coffee-Script using below command, it gives error and warnings. I don't know what to do. Please help me.

[ec2-user@ip-xxx-xx-xx-xxx /]$ npm install -g coffee-script


npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
/usr/local/lib
└── coffee-script@1.10.0

npm ERR! Linux 4.4.11-23.53.amzn1.x86_64
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "coffee-script"
npm ERR! node v6.3.1
npm ERR! npm v3.10.3
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! at Error (native)
npm ERR! { Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR! at Error (native)
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/lib/node_modules' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! Linux 4.4.11-23.53.amzn1.x86_64
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "coffee-script"
npm ERR! node v6.3.1
npm ERR! npm v3.10.3
npm ERR! path npm-debug.log.3173130556
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall open

npm ERR! Error: EACCES: permission denied, open 'npm-debug.log.3173130556'
npm ERR! at Error (native)
npm ERR! { Error: EACCES: permission denied, open 'npm-debug.log.3173130556'
npm ERR! at Error (native)
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'open',
npm ERR! path: 'npm-debug.log.3173130556' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request:
npm ERR! /npm-debug.log


Also I tried :

[ec2-user@ip-xxx-xx-xx-xx /]$ sudo npm install -g coffee-script
sudo: npm: command not found

Answer

Your NPM installation is in a privileged space forcing you to use sudo to make any changes. The problem, is that you're PATH isn't being passed to the sudo'd shell.

You can modify the sudoers PATH by editing the secure_path field in /etc/sudoers.

If you just want to get it installed, provide the full path to npm.

sudo $(which npm) install -g coffee-script