5

I have written a node js program which contained a method called AWS.config.update(). When I tried to run it on terminal, I got an error:

Error: Cannot find module 'aws-sdk'

1
  • I would add the 'aws-sdk' tag Commented Aug 4, 2016 at 22:40

4 Answers 4

11

Go to the folder where your node application is installed:

cd location/to/your/folder

And then run this to install the aws-sdk:

npm install aws-sdk

Sign up to request clarification or add additional context in comments.

Comments

1

After npm install aws-sdk be sure that your package.json specifies the exact version of the new dependency, such as:

"dependencies": {
    "aws-sdk": "2.4.12",

Comments

1

Refer https://www.npmjs.com/package/aws-sdk to see various ways to install aws-sdk.

I prefer always adding dependency on package.json

"dependencies": {
    "aws-sdk": "^2.182.0"
}

and run npm install

Comments

1

I was trying to achieve same thing and got same error

I had installed aws-sdk globally using npm i -g aws-sdk

Note running the node file from command line const AWS = require('aws-sdk') would not work, if there is no local node_modules folder which contains aws-sdk

Solution only for MAC

const AWS = require('/usr/local/lib/node_modules/aws-sdk');

For other OS, find the location of globally installed node_modules

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.