Applications

NodeJS on Windows User Guide

| Product: NodeJS on Windows

Overview

This guide covers the deployment and use of Node.js on Windows Server using cloudimg AMIs from the AWS Marketplace. Node.js is a JavaScript runtime built on Chrome's V8 engine, enabling server side JavaScript execution for building scalable network applications.

What's included in this AMI:

  • Node.js v20.12.2 with npm package manager
  • Node.js desktop shortcut for quick access to the REPL
  • Command Prompt with Node.js in the system PATH
  • Windows Server with Remote Desktop access
  • 24/7 cloudimg support with guaranteed 24 hour response SLA

Prerequisites

Before launching this AMI, ensure you have:

  1. An active AWS account
  2. An active subscription to the NodeJS on Windows listing on AWS Marketplace
  3. An EC2 key pair for password decryption
  4. A Remote Desktop client application

Recommended Instance Type: t3.medium (2 vCPU, 4 GB RAM) or larger. The minimum requirements are 1 vCPU, 1 GB RAM, and 30 GB disk space.

Step 1: Launch the AMI

  1. Navigate to the AWS Marketplace and search for "NodeJS Windows cloudimg"
  2. Click Continue to Subscribe, accept the terms, then Continue to Configuration
  3. Select your preferred Region and Software Version
  4. Click Continue to Launch
  5. Choose Launch through EC2 for full control over instance configuration
  6. Select your instance type (t3.medium recommended)
  7. Configure storage: 30 GB gp3 minimum
  8. Configure your Security Group with the following inbound rules:
Port Protocol Source Purpose
3389 TCP Your IP Remote Desktop (RDP) access

Note: Add additional port rules based on your application needs (for example, port 3000 for Express.js development servers).

  1. Select your EC2 key pair and launch the instance

Step 2: Retrieve the Windows Password

Wait for the EC2 instance to pass 2/2 status checks.

  1. Open the AWS Console and navigate to EC2 > Instances
  2. Select your instance
  3. Click Actions > Security > Get Windows password
  4. Click Browse and upload your EC2 key pair .pem file
  5. Click Decrypt password
  6. Note the Username (Administrator) and the decrypted Password

Important: It may take up to 15 minutes after launch before the Windows password is available.

Step 3: Connect via Remote Desktop

Open your Remote Desktop client:

On Windows: 1. Press Win + R, type mstsc, and press Enter 2. Enter the public IP address of your instance 3. Click Connect

On macOS: 1. Open Microsoft Remote Desktop 2. Click Add PC and enter the public IP address 3. Double click the connection to connect

When prompted: - Username: Administrator - Password: The decrypted value from Step 2

If a certificate warning appears, click Continue to proceed.

Step 4: Verify Node.js Installation

Once connected, open the Node.js desktop shortcut or Command Prompt and verify the installation:

node --version

Expected output:

v20.12.2

Check npm is available:

npm --version

Launch the Node.js REPL (interactive shell):

node

You will see the interactive prompt:

Welcome to Node.js v20.12.2.
Type ".help" for more information.
>

Type .exit or press Ctrl + C twice to exit the REPL.

Step 5: Create and Run a Node.js Application

Create a simple HTTP server:

  1. Create a project directory: cmd mkdir C:\Users\Administrator\Documents\my-app cd C:\Users\Administrator\Documents\my-app

  2. Create server.js: cmd notepad server.js

  3. Enter the following code: javascript const http = require('http'); const server = http.createServer((req, res) => { res.writeHead(200, { 'Content-Type': 'text/plain' }); res.end('Hello from Node.js on cloudimg AWS!\n'); }); server.listen(3000, () => { console.log('Server running at http://localhost:3000/'); });

  4. Run the server: cmd node server.js

  5. Open a browser and navigate to http://localhost:3000

Using npm

Initialize a new project:

npm init -y

Install a package:

npm install express

Install packages globally:

npm install -g nodemon

Run a script defined in package.json:

npm start

Server Components

Component Version
Node.js v20.12.2
npm Included with Node.js

Filesystem Layout

Drive Description
C:\ System drive with Windows and Node.js installation

Key directories:

Directory Purpose
C:\Program Files\nodejs Node.js installation
C:\Users\Administrator\AppData\Roaming\npm Globally installed npm packages
C:\Users\Administrator\Documents Default working directory

Troubleshooting

Node command not found

  1. Open Command Prompt and type node --version
  2. Check that Node.js is in the system PATH: echo %PATH%
  3. Restart Command Prompt after any PATH changes

npm install fails

  1. Verify internet connectivity: ping google.com
  2. Check proxy settings if behind a firewall: npm config list
  3. Clear the npm cache: npm cache clean --force
  4. Check available disk space on C:\

Application cannot bind to port

  1. Verify no other process is using the port: netstat -an | findstr <port>
  2. Ensure your security group allows the port if accessing from outside
  3. Check Windows Firewall settings

Cannot connect via RDP

  1. Verify the instance has passed 2/2 status checks
  2. Check that your security group allows port 3389 from your IP
  3. Wait up to 15 minutes for the Windows password to be available

Security Recommendations

  • Change the Administrator password after first login
  • Restrict RDP access: Only allow port 3389 from your specific IP address
  • Open only necessary ports: Only expose application ports that need external access
  • Use environment variables for secrets: Never hardcode API keys or passwords in application code
  • Keep Node.js updated: Check for security updates regularly
  • Enable Windows Update: Keep the OS patched with the latest security updates
  • Audit npm packages: Use npm audit to check for known vulnerabilities in dependencies

Support

If you encounter any issues with this product, contact cloudimg support:

  • Email: support@cloudimg.co.uk
  • Website: www.cloudimg.co.uk
  • Support hours: 24/7 with guaranteed 24 hour response SLA