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

Laravel 5.6中用Laravel Mix构建React应用遇write EPIPE错误求助

Fixing "Module build failed: Error: write EPIPE" with Laravel Mix React & CSS Imports

Hey there, let's get this EPIPE error sorted out for your Laravel 5.6 + React setup on Ubuntu 16.04!

What's Causing the Issue?

Your processCssUrls: false option works perfectly for your SCSS build because it targets the sass-loader config. But when using mix.react(), the CSS imports in your React modules are handled by css-loader (not sass-loader), so that option doesn't apply there. When css-loader tries to process URLs in those imported CSS files, it triggers a sub-process crash that throws the EPIPE error.

Step-by-Step Solutions

1. Disable URL Processing for css-loader

Override the webpack config to tell css-loader to skip handling URLs entirely. Add this to your webpack.mix.js:

mix.react('resources/assets/js/app.js', 'public/js')
    .sass('resources/assets/sass/app.scss', 'public/css')
    .options({
        processCssUrls: false // Keeps working for SCSS
    })
    .webpackConfig({
        module: {
            rules: [
                {
                    test: /\.css$/,
                    use: [
                        {
                            loader: 'css-loader',
                            options: {
                                url: false // Disable URL processing for all CSS imports
                            }
                        }
                    ]
                }
            ]
        }
    });

2. Clean Your Build Cache & Dependencies

Stale cache or corrupted node modules can cause weird errors like this. Run these commands in your project root:

# Delete Mix's cache
npm run clean

# Wipe node modules and lock file
rm -rf node_modules package-lock.json

# Reinstall dependencies
npm install

# Rebuild your assets
npm run dev

3. Upgrade Your Node.js Version

Node 9.6.1 is a non-LTS, outdated release. Laravel 5.6 is compatible with Node 8.x or 10.x LTS versions, which are far more stable. EPIPE errors sometimes pop up due to version mismatches between Node and webpack loaders. Upgrading to a stable LTS version might resolve the issue entirely.

4. Check Third-Party CSS Imports

If the error persists, take a look at the CSS files being imported in your React modules. Some third-party libraries might have malformed relative URLs or references to non-existent assets. You can either:

  • Manually fix those URLs in the imported CSS
  • Use ignore-loader to skip processing specific problematic files (though the css-loader fix above is more universal)

Final Notes

Start with the webpack config tweak — that's the most direct fix for the URL processing conflict. If that doesn't work, move on to cleaning dependencies and upgrading Node.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.21 06:53:17