I'm trying to run a simple node.js script to describe an instance, but I get:
module.js: 340
Error: Cannot find module 'aws-lib'
I have all the EC2 node.js library files in the same directory as the script, but how do I include them?
var aws = require("aws-lib");
ec2 = aws.createEC2Client(*redacted*, *redacted*);
ec2.call("DescribeInstances", {}, function(err, result) {
console.log(JSON.stringify(result));
});
You don't install the module actually. Go the folder where your node application exists, then install the module there, like:
cd /path/to/your/node/application/ // Since you should be in your app folder
sudo npm cache clear // Just in case
sudo npm install aws-lib // Actual loading command
These commands will create a folder called node_modules
in your application folder. Then you can use aws-lib
.