Skip to content
This repository was archived by the owner on Nov 30, 2023. It is now read-only.

Latest commit

 

History

History

javascript-node

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

IMPORTANT NOTE: We're starting to migrate contents of this repo to the devcontainers org, as part of the work on the open dev container specification.

We'll now be publishing the javascript-node image from devcontainers/images/src/javascript-node.

For more details, you can review the announcement issue.

Node.js & JavaScript

Summary

Develop Node.js based applications. Includes Node.js, eslint, nvm, and yarn.

Metadata Value
Contributors The VS Code Team
Categories Core, Languages
Definition type Dockerfile
Published image mcr.microsoft.com/vscode/devcontainers/javascript-node
Available image variants 18 / 18-bullseye, 16 / 16-bullseye, 14 / 14-bullseye, 18-buster, 16-buster, 14-buster (full list)
Published image architecture(s) x86-64, arm64/aarch64 for bullseye variants
Works in Codespaces Yes
Container host OS support Linux, macOS, Windows
Container OS Debian
Languages, platforms Node.js, JavaScript

See history for information on the contents of published images.

Using this definition

While the definition itself works unmodified, you can select the version of Node.js the container uses by updating the VARIANT arg in the included devcontainer.json (and rebuilding if you've already created the container).

// Or you can use 16-bullseye or 16-buster if you want to pin to an OS version
"args": { "VARIANT": "16" }

You can also directly reference pre-built versions of .devcontainer/base.Dockerfile by using the image property in .devcontainer/devcontainer.json or updating the FROM statement in your own Dockerfile with one of the following:

  • mcr.microsoft.com/vscode/devcontainers/javascript-node (latest)
  • mcr.microsoft.com/vscode/devcontainers/javascript-node:18 (or 18-bullseye, 18-buster to pin to an OS version)
  • mcr.microsoft.com/vscode/devcontainers/javascript-node:16 (or 16-bullseye, 16-buster to pin to an OS version)
  • mcr.microsoft.com/vscode/devcontainers/javascript-node:14 (or 14-bullseye, 14-buster to pin to an OS version)

You can decide how often you want updates by referencing a semantic version of each image. For example:

  • mcr.microsoft.com/vscode/devcontainers/typescript-node:0-16 (or 0-16-bullseye, 0-16-buster)
  • mcr.microsoft.com/vscode/devcontainers/typescript-node:0.204-16 (or 0.204-16-bullseye, 0.204-16-buster)
  • mcr.microsoft.com/vscode/devcontainers/typescript-node:0.204.0-16 (or 0.204.0-16-bullseye, 0.204.0-16-buster)

However, we only do security patching on the latest non-breaking, in support versions of images (e.g. 0-16). You may want to run apt-get update && apt-get upgrade in your Dockerfile if you lock to a more specific version to at least pick up OS security updates.

See history for information on the contents of each version and here for a complete list of available tags.

Alternatively, you can use the contents of base.Dockerfile to fully customize your container's contents or to build it for a container host architecture not supported by the image.

Beyond Node.js and git, this image / Dockerfile includes eslint, zsh, Oh My Zsh!, a non-root vscode user with sudo access, and a set of common dependencies for development. Node Version Manager (nvm) is also included in case you need to use a different version of Node.js than the one included in the image.

Adding the definition to a project or codespace

  1. If this is your first time using a development container, please see getting started information on setting up Remote-Containers or creating a codespace using GitHub Codespaces.

  2. To use the pre-built image:

    1. Start VS Code and open your project folder or connect to a codespace.
    2. Press F1 select and Add Development Container Configuration Files... command for Remote-Containers or Codespaces.
    3. Select this definition. You may also need to select Show All Definitions... for it to appear.
  3. To build a custom version of the image instead:

    1. Clone this repository locally.
    2. Start VS Code and open your project folder or connect to a codespace.
    3. Use your local operating system's file explorer to drag-and-drop the locally cloned copy of the .devcontainer folder for this definition into the VS Code file explorer for your opened project or codespace.
    4. Update .devcontainer/devcontainer.json to reference "dockerfile": "base.Dockerfile".
  4. After following step 2 or 3, the contents of the .devcontainer folder in your project can be adapted to meet your needs.

  5. Finally, press F1 and run Remote-Containers: Reopen Folder in Container or Codespaces: Rebuild Container to start using the definition.

Testing the definition

This definition includes some test code that will help you verify it is working as expected on your system. Follow these steps:

  1. If this is your first time using a development container, please follow the getting started steps to set up your machine.
  2. Clone this repository.
  3. Start VS Code, press F1, and select Remote-Containers: Open Folder in Container...
  4. Select the containers/javascript-node folder.
  5. After the folder has opened in the container, press F5 to start the project. This will automatically run npm install before starting it.
  6. Once the project is running, press F1 and select Remote-Containers: Forward Port from Container...
  7. Select port 3000 and click the "Open Browser" button in the notification that appears.
  8. You should see "Hello remote world!" after the page loads.
  9. From here, you can add breakpoints or edit the contents of the test-project folder to do further testing.

License

Copyright (c) Microsoft Corporation. All rights reserved.

Licensed under the MIT License. See LICENSE.