node.js - Webpack 构建失败并出现 EPIPE 错误(仅限 Linux 子系统)

标签 node.js ubuntu npm webpack windows-10

如果我使用已安装 Node/ yarn 的 Windows 版本从命令行运行 Webpack,我有一个编译得很好的项目。但是,当我尝试从 Linux 子系统构建 Webpack 时,它会因以下错误而中断:

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.

注意:当我从 Linux 和 Windows 单独尝试时,我确实清除了 node_modules 并重新下载了依赖项。

目前,这是唯一有这个问题的项目,我所有的其他项目都工作得很好。

这是我的依赖项:
  "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"
  }

最佳答案

据此GitHub issue问题在于 image-webpack-loader ,该线程中有多种解决方案:

最受欢迎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



还有this

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



this :

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



备注 :旁注,favicons-webpack-plugin也导致了同样的问题。(来自@w9jds 的评论)

关于node.js - Webpack 构建失败并出现 EPIPE 错误(仅限 Linux 子系统),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53681041/

相关文章:

javascript - 对象传播运算符在 Node 8.6 的 webpack 上被检测为错误

python - 使用 Fabric 检查路径是否存在

ubuntu - 可视代码使用的最大文件描述符

javascript - 在成功安装 sqlite3 后尝试运行代码时如何修复此 "module not found error"?

javascript - 如何获取所有可用 Node.js 模块的列表?

node.js - 如何将音频数据从 Wavesurfer 区域复制到新的音频缓冲区?

javascript - 在express 4中从routes/index设置模板变量

javascript - 当我将 'console.log(err.message)' 放入 express 应用程序的错误处理程序中时,它会无休止地记录,但为什么呢?

linux - 无法在 Docker 容器中使用 sudo 编辑环境文件

javascript - 使用 WebPack 将 SCSS 和 CSS 合并到一个文件中