【发布时间】:2020-06-07 08:11:33
【问题描述】:
我一直在开发一个带有 nodejs 后端的 React 应用程序。现在,当我运行npm run build 时出现此错误。我已将 node 和 npm 更新到最新版本。我在控制台中收到以下错误日志。
$ npm run build
> client@0.1.0 build C:\Demos\mern-course\client
> react-scripts build
Creating an optimized production build...
Failed to compile.
./src/App.css
ReferenceError: loader is not defined
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! client@0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the client@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
我的package.json如下。
{
"name": "client",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.4.0",
"@testing-library/user-event": "^7.2.1",
"axios": "^0.19.2",
"bootstrap": "^4.4.1",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-redux": "^7.2.0",
"react-scripts": "^3.4.0",
"react-transition-group": "^4.3.0",
"reactstrap": "^8.4.1",
"redux": "^4.0.5",
"redux-thunk": "^2.3.0",
"uuid": "^3.4.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"proxy": "http://localhost:5000",
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
【问题讨论】:
-
您添加的错误详细信息没有
ReferenceError: loader is not defined显示在哪里? -
请在终端/控制台中
npm ERR! code ELIFECYCLE这一行上方提供更多实际错误。 -
@Chathura Devinda 请编辑您的问题。
-
编译器显示错误在您的 app.css 文件中,您可以浏览文件并检查文件中的“加载器”
-
@AkhilAravind app.css 文件仅包含一些 css 样式。我已经替换了初始 creat-react-app 模板中的所有默认内容。
标签: node.js reactjs redux react-redux