c++dockervisual-studiodevcontainer

Visual Studio unable to find npm and fails change of target system to dev container


I'm getting the following error when I try to open a dev container in VS 2022:

Failed to change target system to '[Dev Container]': Unable to find 'npm'. Please install it and try again.

This is the .devcontainer/devcontainer.json file:

{
  "name": "CPP dev container",
  "image": "link_to_image",
  "customizations": {
    "vscode": {
      "extensions": [
        "ms-vscode.cmake-tools",
        "llvm-vs-code-extensions.vscode-clangd",
        "twxs.cmake",
        "xaver.clang-format",
        "ms-vscode.cpptools"
      ]
    }
  }
}

It works all fine in VS Code, but I also want it to work with Visual Studio.

These are the versions I'm using:

I tried to include npm in the image and to make sure npm is installed on my Windows 11 laptop as well. The image is based on the Debian distro.


Solution

  • This happened to me when using docker from WSL, you need to install npm to the WSL machine