6

I created an elastic beanstalk node.js app on AWS, which created the EC2 and RDS server for me. I am using putty to connect to my Linux EC2 instance, which is successfully logged in.

But the following command doesn't work:

node -v
npm install express -g
node

it gives me an error:

bash: node: command not found

4 Answers 4

16

Node is automatically installed on your instance for elastic beanstalk. It's not in the path.

Look for node installation under /opt/elasticbeanstalk/node-install/ folder.

You shouldn't be installing modules from command line. The preferred way to install node modules on elastic beanstalk is thru package.json. Dependent modules are automatically installed on the instance by aws.

3
  • 2
    You say you shouldn't be installing modules from command line. Is that documented somewhere or just an opinion? If I npm install --save they get added to my package json anyway.
    – user602525
    Aug 25, 2014 at 16:56
  • 2
    It's a standard for deployment of node applications - you should only need to npm install <module_name> during development.
    – mwotton
    Nov 10, 2014 at 0:53
  • 3
    You shouldn't be installing anything on EB yourself because the whole idea of EB is that it spins up new instances if your CPU (or other) usage gets too high. The newly spawned instances would be missing whatever modules you installed yourself. Mar 4, 2016 at 18:53
4

you should find out which node version is being used right now. Then you can use that in your PATH and use npm/node binary..

grep node /var/log/nodejs/nodejs.log

export PATH=$PATH:/opt/elasticbeanstalk/node-install/node-v6.11.5-linux-x64/bin/
1

Assuming you're using Amazon Linux 3.4:

> rpm -Uvh http://download-i2.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm

> sudo yum install nodejs npm --enablerepo=epel

That should do it.

1
1

You can find out where node is installed, and npm, by running ps aux | grep node. This will show you the directory it is being run out of. This is how they give you the ability to pick your version of node, by installing multiple versions. But as palanik says, no need to try to do this manually, unless you are trouble shooting. Which is the PITA on AWS, but that's another discussion.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.