无法编译构建

时间:2018-10-28 14:54:51

标签: node.js reactjs npm material

告诉我可能是什么。该项目是使用create-react-app命令创建的。 package.json //

"name": "front",
"version": "1.0.0",
"private": true,
"proxy": "http://127.0.0.1:8000",
"dependencies": {
  "@material-ui/core": "^3.3.2",
  "@material-ui/icons": "^3.0.1",
  "bootstrap": "^4.1.3",
  "history": "^4.7.2",
  "jwt-decode": "^2.2.0",
  "material-ui": "^0.20.2",
  "react": "^16.5.1",
  "react-dom": "^16.5.1",
  "react-redux": "^5.0.7",
  "react-router-dom": "^4.3.1",
  "react-router-redux": "^5.0.0-alpha.9",
  "react-scripts": "1.1.5",
  "react-transition-group": "^1.1.2",
  "reactstrap": "^6.3.1",
  "redux": "^4.0.0",
  "redux-api-middleware": "^2.0.0-beta.3",
  "redux-persist": "^5.0.0-beta.7",
  "redux-persist-transform-filter": "0.0.18",
  "redux-thunk": "^2.3.0"
},
"scripts": {
  "start": "react-scripts start",
  "build": "react-scripts build",
  "test": "react-scripts test --env=jsdom",
  "eject": "react-scripts eject"
}

我搜索了网。没找到合适的东西。另外,许多解决方案都需要一个webpack配置文件。谢谢你的帮助! 当我使用命令npm run build时,得到以下结果:

Creating an optimized production build...
Failed to compile.

Failed to minify the code from this file: 

     ./node_modules/@material-ui/core/es/styles/withStyles.js:35 

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! front@1.0.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the front@1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/rom/.npm/_logs/2018-10-28T14_41_52_597Z-debug.log

1 个答案:

答案 0 :(得分:1)

如以下github问题所示,您应该修改导入 因此,您的import Button from 'material-ui/es/Button/Button';将成为import { Button, Divider } from 'material-ui';或其他在导入路径中不包含任何/es/的方式:

https://github.com/mui-org/material-ui/issues/9056