You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Windows下Docker部署Laravel遇npm错误:breeze安装命令执行失败

解决Windows通过Docker部署Laravel时执行php artisan breeze:install blade的npm错误

问题场景

在Windows系统通过Docker部署Laravel,执行php artisan breeze:install blade命令时触发npm错误,核心原因是Windows的CMD不支持WSL的UNC路径(\\wsl$\Ubuntu\...),具体报错信息如下:

npm ERR! code 1
npm ERR! path \\wsl$\Ubuntu\home\p7\chirper\node_modules\esbuild
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node install.js
npm ERR! '\\wsl$\Ubuntu\home\p7\chirper\node_modules\esbuild'
npm ERR! CMD.EXE was started with the above path as the current directory.
npm ERR! UNC paths are not supported.  Defaulting to Windows directory.
npm ERR! node:internal/modules/cjs/loader:998
npm ERR!   throw err;
npm ERR!   ^
npm ERR!
npm ERR! Error: Cannot find module 'C:\Windows\install.js'
npm ERR!     at Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
npm ERR!     at Module._load (node:internal/modules/cjs/loader:841:27)
npm ERR!     at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
npm ERR!     at node:internal/main/run_main_module:23:47 {
npm ERR!   code: 'MODULE_NOT_FOUND',
npm ERR!   requireStack: []
npm ERR! }
npm ERR!
npm ERR! Node.js v18.12.1

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Megaport\AppData\Local\npm-cache\_logs\2022-11-27T21_52_29_015Z-debug-0.log

   INFO  Breeze scaffolding installed successfully.

解决方案

方法一:直接在WSL终端执行命令

  1. 打开WSL的Ubuntu终端
  2. 切换到项目目录:cd /home/p7/chirper
  3. 重新执行php artisan breeze:install blade
    此时npm会在WSL环境内运行,完全避开Windows CMD的UNC路径限制。

方法二:配置npm使用WSL的bash执行脚本

在Windows终端中执行以下命令,让npm调用WSL的bash来运行脚本:

npm config set script-shell "wsl.exe bash"

配置完成后,重新执行php artisan breeze:install blade即可。

方法三:手动完成前端依赖安装

由于报错提示Breeze scaffolding installed successfully,说明后端脚手架已部署完成,可单独处理前端部分:

  1. 进入WSL终端的项目目录
  2. 执行npm install安装所有前端依赖
  3. 执行npm run dev编译前端资源

内容的提问来源于stack exchange,提问作者Flow

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.11 01:42:50