Title: Cant Install KeystoneJS on AWS EC2 - Errors Out
Tags: node.js;mongodb;amazon-web-services;amazon-ec2;keystonejs
Question: I have an EC2 instance that successfully has node and mongo installed on it (I've tested both). I'm trying to install KeystoneJS now, but it's throwing errors. Not really sure where I'm going wrong here. Everything works fine locally, I'm assuming it's something with how my EC2 is configured.

```npm install -g generator-keystone```

results in

```npm ERR! tar.unpack untar error /home/ec2-user/.npm/generator-keystone/0.3.7/package.tgz
npm ERR! Linux 3.14.35-28.38.amzn1.x86_64
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "generator-keystone"
npm ERR! node v0.12.7
npm ERR! npm  v2.11.3
npm ERR! path /usr/local/lib/node_modules/generator-keystone
npm ERR! code EACCES
npm ERR! errno -13

npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/generator-keystone'
npm ERR!     at Error (native)
npm ERR!  { [Error: EACCES, mkdir '/usr/local/lib/node_modules/generator-keystone']
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   path: '/usr/local/lib/node_modules/generator-keystone',
npm ERR!   fstream_type: 'Directory',
npm ERR!   fstream_path: '/usr/local/lib/node_modules/generator-keystone',
npm ERR!   fstream_class: 'DirWriter',
npm ERR!   fstream_stack: 
npm ERR!    [ '/usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:35:25',
npm ERR!      '/usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:47:53',
npm ERR!      'FSReqWrap.oncomplete (fs.js:95:15)' ] }
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!     /home/ec2-user/npm-debug.log
```



```sudo npm install -g generator-keystone```

results in

```sudo: npm: command not found```



Here is another answer: If a command isn't available when you use sudo in Linux its normally because the command hasn't been added to the 'sudo path'.  You can see another question which solves that issue here:

https://askubuntu.com/questions/611528/why-cant-sudo-find-a-command-after-i-added-it-to-path  

I'm assuming you either used Ubuntu or the Amazon Linux image for you EC2 instance ( You should specify in the question in future as errors like this can be solved different ways depending on OS - especially when it comes to PATH variables which is likely what the issue is here).  

The above answer I gave is how to do it on Ubuntu whereas I don't know if that convenience command (sudo visudo) is available in the amazon image.

Also as a side note I'd highly recommend that you look into how to use NVM as a general practice when writing anything which depends on Node.js.  It allows you to have multiple versions of node installed on one machine and adjusts your path accordingly to allow you to switch between which one you are using in each terminal (bash) instance.

(It also makes deployment easier IMO).

https://github.com/creationix/nvm

Good luck!


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2015:00:08/24/15', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<node.js><mongodb><amazon-web-services><amazon-ec2><keystonejs>', 'Title': 'Cant Install KeystoneJS on AWS EC2 - Errors Out', 'ViewCount': 565, 'id': 32173474, 'user_AboutMe': '', 'user_AccountId': 2451984.0, 'user_DisplayName': 'itsclarke', 'user_Reputation': 8301.0, 'user_Views': 318.0, 'user_id': 2138024.0}}