Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Webpack Build Fails with EPIPE error (Linux Subsystem only)

I have a project that compiles just fine if I run Webpack from command line using the windows version of the installed node/yarn. However, the second I try to do a Webpack build from the Linux subsystem, it breaks with the following error:

events.js:167
      throw er; // Unhandled 'error' event
      ^

Error: write EPIPE
    at WriteWrap.afterWrite [as oncomplete] (net.js:788:14)
Emitted 'error' event at:
    at onwriteError (_stream_writable.js:431:12)
    at onwrite (_stream_writable.js:456:5)
    at _destroy (internal/streams/destroy.js:40:7)
    at Socket._destroy (net.js:613:3)
    at Socket.destroy (internal/streams/destroy.js:32:8)
    at WriteWrap.afterWrite [as oncomplete] (net.js:790:10)
error Command failed with exit code 1.

Note: I do clear the node_modules and redownload the dependencies when I try it separately from Linux and Windows.

Currently, this is the only project that has this issue, all of my other projects work just fine.

Here are my dependencies:

  "dependencies": {
    "@date-io/date-fns": "0.0.2",
    "@firebase/app": "^0.3.5",
    "@firebase/auth": "^0.9.0",
    "@firebase/firestore": "^0.9.0",
    "@firebase/storage": "^0.2.4",
    "@material-ui/core": "^3.6.1",
    "@material-ui/icons": "^3.0.1",
    "classnames": "^2.2.6",
    "date-fns": "^2.0.0-alpha.21",
    "isomorphic-fetch": "^2.2.1",
    "material-ui-pickers": "^2.0.4",
    "react": "^16.6.3",
    "react-async-script": "^1.0.0",
    "react-dom": "^16.6.3",
    "react-dropzone": "^7.0.1",
    "react-redux": "^6.0.0",
    "react-router": "^4.3.1",
    "react-router-dom": "^4.3.1",
    "redux": "^4.0.1",
    "redux-actions": "^2.6.4",
    "redux-saga": "^0.16.2",
    "reselect": "^4.0.0"
  },
  "devDependencies": {
    "@babel/core": "^7.2.0",
    "@babel/plugin-proposal-class-properties": "^7.2.1",
    "@babel/preset-env": "^7.2.0",
    "@babel/preset-react": "^7.0.0",
    "@babel/preset-typescript": "^7.1.0",
    "@types/googlemaps": "^3.30.16",
    "@types/node": "^10.12.12",
    "@types/react": "^16.7.13",
    "@types/react-dom": "^16.0.11",
    "@types/react-redux": "^6.0.10",
    "@types/react-router": "^4.4.1",
    "@types/react-router-dom": "^4.3.1",
    "@types/redux-actions": "^2.3.1",
    "@types/webpack": "^4.4.20",
    "babel-loader": "^8.0.4",
    "babel-polyfill": "^6.26.0",
    "css-loader": "^1.0.1",
    "extract-text-webpack-plugin": "^4.0.0-beta.0",
    "favicons-webpack-plugin": "^0.0.9",
    "file-loader": "^2.0.0",
    "html-webpack-plugin": "^3.2.0",
    "image-webpack-loader": "^4.6.0",
    "node-sass": "^4.10.0",
    "path": "^0.12.7",
    "react-svg-loader": "^2.1.0",
    "resolve-url-loader": "^3.0.0",
    "sass-loader": "^7.1.0",
    "source-map-loader": "^0.2.4",
    "style-loader": "^0.23.1",
    "ts-loader": "^5.3.1",
    "tslib": "^1.9.3",
    "tslint": "^5.11.0",
    "tslint-react": "^3.6.0",
    "typescript": "^3.2.2",
    "url-loader": "^1.1.2",
    "webpack": "^4.27.1",
    "webpack-cli": "^3.1.2"
  }
like image 285
w9jds Avatar asked Dec 08 '18 09:12

w9jds


2 Answers

According to this GitHub issue the problem is with image-webpack-loader, there are multiple solutions in that thread:

Most popular solution:

This is apparently an issue with imagemin-mozjpeg. According to this comment imagemin/imagemin-mozjpeg#28 (comment) you need to install libpng16-dev (sudo apt-get install libpng16-dev).

This fixed it for me on Ubuntu 16.04.1 LTS

Also this

updating image-webpack-loader to version 4.5.0 solved this issue

And this:

The downgrade to 3.6.0 worked fine. Everything builds a-ok on Netlify and on Ubuntu 16.04.

Note: Side note, favicons-webpack-plugin also caused this same exact problem.(from @w9jds's comment)

like image 183
Aritra Chakraborty Avatar answered Oct 01 '22 21:10

Aritra Chakraborty


For anyone coming from Google, the answer (for me) was to change the runner value for rails-erb-loader to the following: bundle exec rails:

// config/webpacker/environment.js
environment.loaders.prepend('erb', {
  test: /\.erb$/,
  enforce: 'pre',
  exclude: /node_modules/,
  use: [{
    loader: 'rails-erb-loader',
    options: {
      runner: (/^win/.test(process.platform) ? 'ruby ' : '') + 'bundle exec rails runner' // <- here 
    }
  }] 
})

Got the idea here.

like image 33
Richard Peck Avatar answered Oct 01 '22 19:10

Richard Peck