0

I’ve recently set up a WordPress project inside the WSL2 filesystem (/home/john/projects) and am using DDEV to manage my local environment. After starting the DDEV container, I navigate into my theme directory within the DDEV terminal and run: npm install.

Normally, this process completes within about 30 seconds. However, inside DDEV, it takes much longer (~10 minutes) and eventually fails with the following error related to esbuild:

npm error code 1
npm error path \\wsl.localhost\DDEV\home\john\project\wp-content\themes\project-theme\node_modules\esbuild
npm error command failed
npm error command C:\Windows\system32\cmd.exe /d /s /c node install.js
npm error '\\wsl.localhost\DDEV\home\john\project\wp-content\themes\project-theme\node_modules\esbuild'
npm error CMD.EXE was started with the above path as the current directory.
npm error UNC paths are not supported.  Defaulting to Windows directory.
npm error node:internal/modules/cjs/loader:1228
npm error   throw err;
npm error   ^
npm error
npm error Error: Cannot find module 'C:\Windows\install.js'
npm error     at Function._resolveFilename (node:internal/modules/cjs/loader:1225:15)
npm error     at Function._load (node:internal/modules/cjs/loader:1055:27)
npm error     at TracingChannel.traceSync (node:diagnostics_channel:322:14)
npm error     at wrapModuleLoad (node:internal/modules/cjs/loader:220:24)
npm error     at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:170:5)
npm error     at node:internal/main/run_main_module:36:49 {
npm error   code: 'MODULE_NOT_FOUND',
npm error   requireStack: []
npm error }
npm error
npm error Node.js v22.14.0

I can see that the issue is with esbuild and UNC paths but was unable to find any fixes for this. Any suggestions on how best to debug or fix this?

1
  • 3
    You seem to be running npm on the Windows host against a project in WSL2. Please don't do that. Instead open the WSL2 distro in Terminal and then run npm inside the project using ddev npm ... Commented Jul 23 at 16:26

1 Answer 1

1

This error happens because esbuild install script doesn’t support UNC paths (like \\wsl.localhost\DDEV\...) which Windows uses to access WSL files from Windows apps. When npm install runs inside the DDEV terminal on WSL2, Node tries to run Windows commands but gets confused by UNC paths, causing failure/error.

  1. Run npm install inside WSL directly, not from Windows or UNC paths

  2. Avoid running npm install in mounted Windows folders inside WSL

  3. If you must use Windows terminal, map a drive letter to your WSL path ( net use D: \\wsl$\Ubuntu\home\name ) and run commands from that drive.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.