

AWS App Runner will no longer be open to new customers starting April 30, 2026. If you would like to use App Runner, sign up prior to that date. Existing customers can continue to use the service as normal. For more information, see [AWS App Runner availability change](https://docs.aws.amazon.com/apprunner/latest/dg/apprunner-availability-change.html).

# Using the Node.js platform
<a name="service-source-code-nodejs"></a>

**Important**  
App Runner will end the support for **Node.js 12**, **Node.js 14**, **Node.js 16** and **Node.js 18** on December 1, 2025. For recommendations and more information, see [End of support for managed runtime versions](service-source-code.md#service-source-code.managed-platforms.eos).

The AWS App Runner Node.js platform provides managed runtimes. Each runtime makes it easy to build and run containers with web applications based on a Node.js version. When you use a Node.js runtime, App Runner starts with a managed Node.js runtime image. This image is based on the [Amazon Linux Docker image](https://hub.docker.com/_/amazonlinux) and contains the runtime package for a version of Node.js and some tools. App Runner uses this managed runtime image as a base image, and adds your application code to build a Docker image. It then deploys this image to run your web service in a container.

 You specify a runtime for your App Runner service when you [create a service](manage-create.md) using the App Runner console or the [CreateService](https://docs.aws.amazon.com/apprunner/latest/api/API_CreateService.html) API operation. You can also specify a runtime as part of your source code. Use the `runtime` keyword in a [App Runner configuration file](config-file.md) that you include in your code repository. The naming convention of a managed runtime is *<language-name><major-version>*. 

For valid Node.js runtime names and versions, see [Node.js runtime release information](service-source-code-nodejs-releases.md).

App Runner updates the runtime for your service to the latest version on every deployment or service update. If your application requires a specific version of a managed runtime, you can specify it using the `runtime-version` keyword in the [App Runner configuration file](config-file.md). You can lock to any level of version, including a major or minor version. App Runner only makes lower-level updates to the runtime of your service.

Version syntax for Node.js runtimes: `major[.minor[.patch]]`

For example: `22.14.0`

The following examples demonstrate version locking:
+ `22.14` – Lock the major and minor versions. App Runner updates only patch versions.
+ `22.14.0` – Lock to a specific patch version. App Runner doesn't update your runtime version.

**Topics**
+ [Node.js runtime configuration](#service-source-code-nodejs.config)
+ [Callouts for specific runtime versions](#service-source-code-nodejs.callouts)
+ [Node.js runtime examples](#service-source-code-nodejs.examples)
+ [Node.js runtime release information](service-source-code-nodejs-releases.md)

## Node.js runtime configuration
<a name="service-source-code-nodejs.config"></a>

When you choose a managed runtime, you must also configure, as a minimum, build and run commands. You configure them while [creating](manage-create.md) or [updating](manage-configure.md) your App Runner service. You can do this using one of the following methods:
+ **Using the App Runner console** – Specify the commands in the **Configure build** section of the creation process or configuration tab.
+ **Using the App Runner API** – Call the [CreateService](https://docs.aws.amazon.com/apprunner/latest/api/API_CreateService.html) or [UpdateService](https://docs.aws.amazon.com/apprunner/latest/api/API_UpdateService.html) API operation. Specify the commands using the `BuildCommand` and `StartCommand` members of the [CodeConfigurationValues](https://docs.aws.amazon.com/apprunner/latest/api/API_CodeConfigurationValues.html) data type.
+ **Using a [configuration file](config-file.md)** – Specify one or more build commands in up to three build phases, and a single run command that serves to start your application. There are additional optional configuration settings.

Providing a configuration file is optional. When you create an App Runner service using the console or the API, you specify if App Runner gets your configuration settings directly when it's created or from a configuration file.

With Node.js runtimes specifically, you can also configure the build and runtime using a JSON file named `package.json` in the root of your source repository. Using this file, you can configure the Node.js engine version, dependency packages, and various commands (command line applications). Package managers such as npm or yarn interpret this file as input for their commands.

For example:
+ **npm install** installs packages defined by the `dependencies` and `devDependencies` node in `package.json`.
+ **npm start** or **npm run start** runs the command defined by the `scripts/start` node in `package.json`.

The following is an example `package.json` file.

### package.json
<a name="service-source-code-nodejs.config.package-json-example"></a>

```
{
  "name": "node-js-getting-started",
  "version": "0.3.0",
  "description": "A sample Node.js app using Express 4",
  "engines": {
    "node": "22.14.0"
  },
  "scripts": {
    "start": "node index.js",
    "test": "node test.js"
  },
  "dependencies": {
    "cool-ascii-faces": "^1.3.4",
    "ejs": "^2.5.6",
    "express": "^4.15.2"
  },
  "devDependencies": {
    "got": "^11.3.0",
    "tape": "^4.7.0"
  }
}
```

For more information about `package.json`, see [Creating a package.json file](https://docs.npmjs.com/creating-a-package-json-file) on the *npm Docs* website. 

**Tips**  
If your `package.json` file defines a **start** command, you can use it as a **run** command in your App Runner configuration file, as the following example shows.  

**Example**  
package.json  

  ```
  {
    "scripts": {
      "start": "node index.js"
    }
  }
  ```
apprunner.yaml  

  ```
  run:
    command: npm start
  ```
When you run **npm install** in your development environment, npm creates the file `package-lock.json`. This file contains a snapshot of the package versions npm just installed. Thereafter, when npm installs dependencies, it uses these exact versions. If you install yarn it creates a `yarn.lock` file. Commit these files to your source code repository to ensure that your application is installed with the versions of dependencies that you developed and tested it with.
You can also use an App Runner configuration file to configure the Node.js version and start command. When you do this, these definitions override the ones in `package.json`. A conflict between the `node` version in `package.json` and the `runtime-version` value in the App Runner configuration file causes the App Runner build phase to fail.

## Callouts for specific runtime versions
<a name="service-source-code-nodejs.callouts"></a>

### Node.js 22 and Node.js 18 (revised App Runner build)
<a name="service-source-code-nodejs.callouts.nodejs18"></a>

App Runner now runs an updated build process for applications based on the following runtime versions: Python 3.11, Node.js 22, and Node.js 18. If your application runs on either one of these runtime versions, see [Managed runtime versions and the App Runner build](service-source-code.md#service-source-code.build-detail) for more information about the revised build process. Applications that use all other runtime versions are not affected, and they continue to use the original build process. 

## Node.js runtime examples
<a name="service-source-code-nodejs.examples"></a>

The following examples show App Runner configuration files for building and running a Node.js service. 

**Note**  
The runtime version that's used in these examples is *22.14.0*. You can replace it with a version you want to use. For latest supported Node.js runtime version, see [Node.js runtime release information](service-source-code-nodejs-releases.md).

### Minimal Node.js configuration file
<a name="service-source-code-nodejs.examples.minimal"></a>

This example shows a minimal configuration file that you can use with a Node.js managed runtime. For the assumptions that App Runner makes with a minimal configuration file, see [Configuration file examples](config-file-examples.md#config-file-examples.managed).

**Example apprunner.yaml**  

```
version: 1.0
runtime: nodejs22
build:
  commands:    
    build:
      - npm install --production                                  
run:                              
  command: node app.js
```

### Extended Node.js configuration file
<a name="service-source-code-nodejs.examples.extended"></a>

This example shows the use of all the configuration keys with a Node.js managed runtime.

**Note**  
The runtime version that's used in these examples is *22.14.0*. You can replace it with a version you want to use. For latest supported Node.js runtime version, see [Node.js runtime release information](service-source-code-nodejs-releases.md).

**Example apprunner.yaml**  

```
version: 1.0
runtime: nodejs22
build:
  commands:
    pre-build:
      - npm install --only=dev
      - node test.js
    build:
      - npm install --production
    post-build:
      - node node_modules/ejs/postinstall.js
  env:
    - name: MY_VAR_EXAMPLE
      value: "example"
run:
  runtime-version: 22.14.0
  command: node app.js
  network:
    port: 8000
    env: APP_PORT
  env:
    - name: MY_VAR_EXAMPLE
      value: "example"
```

### Extended Node.js configuration file – Node.js 22 (uses revised build)
<a name="service-source-code-nodejs.examples.extended-v2"></a>

This example shows the use of all the configuration keys with a Node.js managed runtime in the `apprunner.yaml`. This example include a `pre-run` section, since this version of Node.js uses the revised App Runner build.

The `pre-run` parameter is only supported by the revised App Runner build. Do not insert this parameter in your configuration file if your application uses runtime versions that are supported by the original App Runner build. For more information, see [Managed runtime versions and the App Runner build](service-source-code.md#service-source-code.build-detail).

**Note**  
The runtime version that's used in these examples is *22.14.0*. You can replace it with a version you want to use. For latest supported Node.js runtime version, see [Node.js runtime release information](service-source-code-nodejs-releases.md).

**Example apprunner.yaml**  

```
version: 1.0
runtime: nodejs22
build:
  commands:
    pre-build:
      - npm install --only=dev
      - node test.js
    build:
      - npm install --production
    post-build:
      - node node_modules/ejs/postinstall.js
  env:
    - name: MY_VAR_EXAMPLE
      value: "example"
run:
  runtime-version: 22.14.0
  pre-run: 
    - node copy-global-files.js
  command: node app.js
  network:
    port: 8000
    env: APP_PORT
  env:
    - name: MY_VAR_EXAMPLE
      value: "example"
```

### Node.js app with Grunt
<a name="service-source-code-nodejs.examples.grunt"></a>

This example shows how to configure a Node.js application that's developed with Grunt. [Grunt](https://gruntjs.com/) is a command line JavaScript task runner. It runs repetitive tasks and manages process automation to reduce human error. Grunt and Grunt plugins are installed and managed using npm. You configure Grunt by including the `Gruntfile.js` file in the root of your source repository.

**Example package.json**  

```
{
  "scripts": {
    "build": "grunt uglify",
    "start": "node app.js"
  },
  "devDependencies": {
    "grunt": "~0.4.5",
    "grunt-contrib-jshint": "~0.10.0",
    "grunt-contrib-nodeunit": "~0.4.1",
    "grunt-contrib-uglify": "~0.5.0"
  },
  "dependencies": {
    "express": "^4.15.2"
  },
}
```

**Example Gruntfile.js**  

```
module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    uglify: {
      options: {
        banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
      },
      build: {
        src: 'src/<%= pkg.name %>.js',
        dest: 'build/<%= pkg.name %>.min.js'
      }
    }
  });

  // Load the plugin that provides the "uglify" task.
  grunt.loadNpmTasks('grunt-contrib-uglify');

  // Default task(s).
  grunt.registerTask('default', ['uglify']);

};
```

**Example apprunner.yaml**  
The runtime version that's used in these examples is *22.14.0*. You can replace it with a version you want to use. For latest supported Node.js runtime version, see [Node.js runtime release information](service-source-code-nodejs-releases.md).

```
version: 1.0
runtime: nodejs22
build:
  commands:
    pre-build:
      - npm install grunt grunt-cli
      - npm install --only=dev
      - npm run build
    build:
      - npm install --production
run:
  runtime-version: 22.14.0
  command: node app.js
  network:
    port: 8000
    env: APP_PORT
```

# Node.js runtime release information
<a name="service-source-code-nodejs-releases"></a>

**Important**  
App Runner will end the support for **Node.js 12**, **Node.js 14**, **Node.js 16** and **Node.js 18** on December 1, 2025. For recommendations and more information, see [End of support for managed runtime versions](service-source-code.md#service-source-code.managed-platforms.eos).

**Note**  
App Runner’s standard deprecation policy is to deprecate a runtime when any major component of the runtime reaches the end of community long-term support (LTS) and security updates are no longer available. In some cases, App Runner may delay deprecation of a runtime for a limited period, beyond the end-of-support date of the language version supported by the runtime. An example of such a case could be to extend support for a runtime to allow customers time for migration.

This topic lists the full details for the Node.js runtime versions that App Runner supports.


**Supported runtime versions — revised App Runner build**  
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/apprunner/latest/dg/service-source-code-nodejs-releases.html)

**Note**  
App Runner provides a revised build process for specific major runtimes that have been released more recently. Because of this you'll see references to *revised App Runner build* and *original App Runner build* in certain sections of this document. For more information, see [Managed runtime versions and the App Runner build](service-source-code.md#service-source-code.build-detail).


**Supported runtime versions — revised App Runner build**  
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/apprunner/latest/dg/service-source-code-nodejs-releases.html)




**Supported runtime versions — original App Runner build**  
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/apprunner/latest/dg/service-source-code-nodejs-releases.html)