当我使用npm命令启动我的应用程序时,一切正常,但是当我使用npm命令运行构建应用程序时,出现错误
13 verbose stack Error: test@0.1.0 build: `react-scripts build`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:304:16)
13 verbose stack at emitTwo (events.js:126:13)
13 verbose stack at EventEmitter.emit (events.js:214:7)
13 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at emitTwo (events.js:126:13)
13 verbose stack at ChildProcess.emit (events.js:214:7)
13 verbose stack at maybeClose (internal/child_process.js:925:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
有什么问题吗?
编辑 我使用命令create-react-app myapp创建应用程序。 Index.js看起来像
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import registerServiceWorker from './registerServiceWorker';
import 'bootstrap/dist/css/bootstrap.css';
import {BrowserRouter} from 'react-router-dom';
ReactDOM.render(
<BrowserRouter>
<App/>
</BrowserRouter>
, document.getElementById('app'));
registerServiceWorker();
还有package.json
{
"name": "mailsender-client",
"version": "0.1.0",
"private": true,
"dependencies": {
"bootstrap": "^4.1.3",
"jquery": "^3.3.1",
"moment": "^2.22.2",
"query-string": "^6.5.2",
"react": "^16.4.1",
"react-dom": "^16.4.1",
"react-router": "^3.2.1",
"react-router-dom": "^4.3.1",
"react-scripts": "1.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
答案 0 :(得分:1)
在我的情况下,需要将相关性查询字符串替换为qs。 有关详细信息,请参见https://github.com/facebook/create-react-app/issues/3734
答案 1 :(得分:1)
尝试使用npm审核修复程序。当我遇到依赖问题时,这对我有用。
答案 2 :(得分:0)
该问题也可能是由现有警告引起的。
在npm run build
期间出现此类错误,“由于process.env.CI = true
将警告视为错误。大多数CI服务器会自动设置它。无法编译”
摆脱警告或将此变量设置为false