Bug: Extension fails to activate in Dev Container environment - Cannot find module '@nuxtlabs/monarch-mdc'
Description:
The nuxt.mdc extension fails to activate when running within a VS Code Dev Container environment. This prevents any of the extension's features, such as syntax highlighting or formatting, from working.
Steps to Reproduce:
- Connect to a remote Server
- Create a project with the
devcontainer.jsonconfiguration provided below. - Open the project folder in VS Code.
- When prompted, select "Reopen in Container".
- Allow the container to build and VS Code to connect fully.
- Open an
.mdcfile (or wait for the extension to attempt activation). - Check the "Output" panel in VS Code, selecting "Extension Host (Server)" from the dropdown menu.
Expected Behavior:
The nuxt.mdc extension should activate successfully without errors, providing syntax highlighting and formatting capabilities for .mdc files within the dev container.
Actual Behavior: The extension fails to activate, and the following error message appears in the "Extension Host (Server)" output log:
2025-04-09 13:30:42.476 [error] Activating extension Nuxt.mdc failed due to an error:
2025-04-09 13:30:42.476 [error] Error: Cannot find module '@nuxtlabs/monarch-mdc'
Require stack:
- /home/vscode/.vscode-server/extensions/nuxt.mdc-0.2.4/out/extension.js
- /home/vscode/.vscode-server/cli/servers/Stable-7c6fdfb0b8f2f675eb0b47f3d95eeca78962565b/server/out/vs/workbench/api/node/extensionHostProcess.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1225:15)
at Function.t._resolveFilename (file:///home/vscode/.vscode-server/cli/servers/Stable-7c6fdfb0b8f2f675eb0b47f3d95eeca78962565b/server/out/vs/workbench/api/node/extensionHostProcess.js:183:22672)
at Function.Module._load (node:internal/modules/cjs/loader:1051:27)
at Function.e._load (file:///home/vscode/.vscode-server/cli/servers/Stable-7c6fdfb0b8f2f675eb0b47f3d95eeca78962565b/server/out/vs/workbench/api/node/extensionHostProcess.js:197:1509)
at Function.t._load (file:///home/vscode/.vscode-server/cli/servers/Stable-7c6fdfb0b8f2f675eb0b47f3d95eeca78962565b/server/out/vs/workbench/api/node/extensionHostProcess.js:183:22390)
at Function.i._load (file:///home/vscode/.vscode-server/cli/servers/Stable-7c6fdfb0b8f2f675eb0b47f3d95eeca78962565b/server/out/vs/workbench/api/node/extensionHostProcess.js:175:24781)
at Module.require (node:internal/modules/cjs/loader:1311:19)
at require (node:internal/modules/helpers:179:18)
at Object.<anonymous> (/home/vscode/.vscode-server/extensions/nuxt.mdc-0.2.4/out/extension.js:5:23)
at Module._compile (node:internal/modules/cjs/loader:1469:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1548:10)
at Module.load (node:internal/modules/cjs/loader:1288:32)
at Function.Module._load (node:internal/modules/cjs/loader:1104:12)
at Function.e._load (file:///home/vscode/.vscode-server/cli/servers/Stable-7c6fdfb0b8f2f675eb0b47f3d95eeca78962565b/server/out/vs/workbench/api/node/extensionHostProcess.js:197:1509)
at Function.t._load (file:///home/vscode/.vscode-server/cli/servers/Stable-7c6fdfb0b8f2f675eb0b47f3d95eeca78962565b/server/out/vs/workbench/api/node/extensionHostProcess.js:183:22390)
at Function.i._load (file:///home/vscode/.vscode-server/cli/servers/Stable-7c6fdfb0b8f2f675eb0b47f3d95eeca78962565b/server/out/vs/workbench/api/node/extensionHostProcess.js:175:24781)
at Module.require (node:internal/modules/cjs/loader:1311:19)
at require (node:internal/modules/helpers:179:18)
at vV.xb (file:///home/vscode/.vscode-server/cli/servers/Stable-7c6fdfb0b8f2f675eb0b47f3d95eeca78962565b/server/out/vs/workbench/api/node/extensionHostProcess.js:183:23710)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Promise.all (index 0)
Consequently, features like formatting (e.g., with "mdc.enableFormatting": true in settings.json) do not work.
Environment:
- VS Code Version: 1.99.1
- Extension Version:
nuxt.mdc0.2.4 - Operating System (Host): macOS 15.3.2
- Operating System (Container): Debian GNU/Linux 12 (bookworm) via Dev Container
- Dev Container Configuration (
devcontainer.json):// For format details, see https://aka.ms/devcontainer.json. For config options, see the { "name": "Default", "image": "mcr.microsoft.com/devcontainers/base:debian", "features": { "ghcr.io/devcontainers/features/python:1": { "version": "3.13.2", "toolsToInstall": "uv" }, "ghcr.io/devcontainers/features/node:1": {}, "ghcr.io/devcontainers/features/docker-in-docker:2": {} }, "postCreateCommand": "curl -fsSL https://bun.sh/install | bash", "customizations": { "vscode": { "extensions": [ "bradlc.vscode-tailwindcss", "dbaeumer.vscode-eslint", "charliermarsh.ruff", "esbenp.prettier-vscode", "ms-azuretools.vscode-docker", "GitHub.copilot", "GitHub.copilot-chat", "eamodio.gitlens", "ms-python.python", "ms-python.debugpy", "Vue.volar", "nuxt.mdc", // <-- Extension being installed here "rooveterinaryinc.roo-cline" ] } } }
Additional Context:
The error message Error: Cannot find module '@nuxtlabs/monarch-mdc' suggests a dependency required by the extension is not being correctly installed or located within the remote server environment of the dev container.
I'm getting this even without dev container.
I think we need to use a proper build tool e.g. unbuild / esbuild / rollup ... to bundle the extension so that the @nuxtlabs/monarch-mdc package is included as a inline dependency.
@farnabaz I just tried the released version and I too see the following error:
2025-04-15 13:26:25.552 [error] Error: Cannot find module '@nuxtlabs/monarch-mdc'
It's odd because it resolves when utilizing the generate command. Looking into it
I originally fixed this here: https://github.com/nuxtlabs/vscode-mdc/pull/46
I'm guessing these two dependencies keys in the GitHub Action pipeline might be the culprit?
https://github.com/nuxtlabs/vscode-mdc/blob/62edface7e07e54dbe7efd09a9fedd0d5bdd77c2/.github/workflows/deploy.yml#L30-L36
Alternatively, the .npmrc file may not be respected in the build/release pipeline as it requires the node-linker=hoisted as well
Fixed in v0.3.1.