Using Amazon Cloud9 with the Amazon SDK for JavaScript - Amazon SDK for JavaScript
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

We announced the upcoming end-of-support for Amazon SDK for JavaScript v2. We recommend that you migrate to Amazon SDK for JavaScript v3. For dates, additional details, and information on how to migrate, please refer to the linked announcement.

Using Amazon Cloud9 with the Amazon SDK for JavaScript

You can use Amazon Cloud9 with the Amazon SDK for JavaScript to write and run your JavaScript in the browser code —as well as write, run, and debug your Node.js code—using just a browser. Amazon Cloud9 includes tools such as a code editor and terminal, plus a debugger for Node.js code. Because the Amazon Cloud9 IDE is cloud based, you can work on your projects from your office, home, or anywhere using an internet-connected machine. For general information about Amazon Cloud9, see the Amazon Cloud9 User Guide.

Follow these steps to set up Amazon Cloud9 with the SDK for JavaScript:

Step 1: Set up Your Amazon Account to Use Amazon Cloud9

Start to use Amazon Cloud9 by signing in to the Amazon Cloud9 console as an Amazon Identity and Access Management (IAM) entity (for example, an IAM user) who has access permissions for Amazon Cloud9 in your Amazon account.

To set up an IAM entity in your Amazon account to access Amazon Cloud9, and to sign in to the Amazon Cloud9 console, see Team Setup for Amazon Cloud9 in the Amazon Cloud9 User Guide.

Step 2: Set up Your Amazon Cloud9 Development Environment

After you sign in to the Amazon Cloud9 console, use the console to create an Amazon Cloud9 development environment. After you create the environment, Amazon Cloud9 opens the IDE for that environment.

See Creating an Environment in Amazon Cloud9 in the Amazon Cloud9 User Guide for details.

Note

As you create your environment in the console for the first time, we recommend that you choose the option to Create a new instance for environment (EC2). This option tells Amazon Cloud9 to create an environment, launch an Amazon EC2 instance, and then connect the new instance to the new environment. This is the fastest way to begin using Amazon Cloud9.

Step 3: Set up the SDK for JavaScript

After Amazon Cloud9 opens the IDE for your development environment, follow one or both of the following procedures to use the IDE to set up the SDK for JavaScript in your environment.

To set up the SDK for JavaScript for Node.js

  1. If the terminal isn't already open in the IDE, open it. To do this, on the menu bar in the IDE, choose Window, New Terminal.

  2. Run the following command to use npm to install the SDK for JavaScript.

    npm install aws-sdk

    If the IDE can't find npm, run the following commands, one at a time in the following order, to install npm. (These commands assume you chose the option to Create a new instance for environment (EC2), earlier in this topic.)

    Warning

    Amazon does not control the following code. Before you run it, be sure to verify its authenticity and integrity. More information about this code can be found in the nvm GitHub repository.

    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash # Download and install Node Version Manager (nvm). . ~/.bashrc # Activate nvm. nvm install node # Use nvm to install npm (and Node.js at the same time).

To set up the SDK for JavaScript in the browser

You don't have to install the SDK for JavaScript to use it in browser scripts. You can load the hosted SDK for JavaScript package directly from Amazon with a script in your HTML pages.

You can download minified and non-minified distributable versions of the current SDK for JavaScript from GitHub at https://github.com/aws/aws-sdk-js/tree/master/dist.

Step 4: Download Example Code

Use the terminal you opened in the previous step to download example code for the SDK for JavaScript into the Amazon Cloud9 development environment. (If the terminal isn't already open in the IDE, open it by choosing Window, New Terminal on the menu bar in the IDE.)

To download the example code, run the following command. This command downloads a copy of all of the code examples used in the official Amazon SDK documentation into your environment's root directory.

git clone https://github.com/awsdocs/aws-doc-sdk-examples.git

To find code examples for the SDK for JavaScript, use the Environment window to open the ENVIRONMENT_NAME\aws-doc-sdk-examples\javascript\example_code, where ENVIRONMENT_NAME is the name of your Amazon Cloud9 development environment.

To learn how to work with these and other code examples, see SDK for JavaScript Code Examples.

Step 5: Run and Debug Example Code

To run code in your Amazon Cloud9 development environment, see Run Your Code in the Amazon Cloud9 User Guide.

To debug Node.js code, see Debug Your Code in the Amazon Cloud9 User Guide.