microsoft / vscode-dev-containers

NOTE: Most of the contents of this repository have been migrated to the new devcontainers GitHub org (https://github.com/devcontainers). See https://github.com/devcontainers/template-starter and https://github.com/devcontainers/feature-starter for information on creating your own!
https://aka.ms/vscode-remote
MIT License
4.7k stars 1.41k forks source link

npm error Cannot find module #1759

Open rubengr opened 11 months ago

rubengr commented 11 months ago

Hi,

I'm trying to run this container in my pc and don't works. The container works, but npm doesn't. It gives this error:

image

In other pc the same project runs correctly. Also i tried the dev container node example and npm works.

dev container:

{
    "name": "Node.js",
    // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
    "image": "mcr.microsoft.com/devcontainers/javascript-node:1-20-bullseye",

    // Features to add to the dev container. More info: https://containers.dev/features.
    "features": {
        "ghcr.io/devcontainers/features/git:1": {}
    },

    // Use 'forwardPorts' to make a list of ports inside the container available locally.
    // "forwardPorts": [],

    // Use 'postCreateCommand' to run commands after the container is created.
    "postCreateCommand": "npm install",

    // Configure tool-specific properties.
    // "customizations": {},

    // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
    // "remoteUser": "root"
}
KevinBonnoron commented 8 months ago

Had the same issue this morning (with vscode version 1.83.1 on ubuntu 22.04). This seems to be related to this issue : https://github.com/microsoft/vscode-remote-release/issues/5516

After setting the Debug auto attach to false and rebuild the container i can now use npm/yarn.