react脚本构建错误代码-134,不创建构建



当我尝试在react应用程序中创建内建并运行时:

`npm run build`

它告诉我这是一个错误,在此之前它工作得很好,不要忘记今天在创建一些UI组件后发生了什么。

以下是我尝试运行npm run build时遇到的错误:

`E:clientpaytify>npm run build
> paytify@0.1.0 build E:clientpaytify
> react-scripts build
Creating an optimized production build...
<--- Last few GCs --->
[11012:0000025D9D438DE0]   274773 ms: Scavenge 1353.8 (1424.5) -> 1353.1 (1425.0) MB, 5.6 / 0.0 ms  
(average mu = 0.163, current mu = 0.106) allocation failure
[11012:0000025D9D438DE0]   274782 ms: Scavenge 1353.9 (1425.0) -> 1353.3 (1425.5) MB, 5.4 / 0.0 ms  
(average mu = 0.163, current mu = 0.106) allocation failure
[11012:0000025D9D438DE0]   274792 ms: Scavenge 1354.1 (1425.5) -> 1353.5 (1426.5) MB, 4.9 / 0.0 ms  
(average mu = 0.163, current mu = 0.106) allocation failure

<--- JS stacktrace --->
==== JS stack trace =========================================
0: ExitFrame [pc: 0000003AD395C5C1]
Security context: 0x03b1e301e6e9 <JSObject>
1: /* anonymous */ [000000FF19B291E1] [E:clientmonaianode_modulessource-maplibsource- 
node.js:~342] [pc=0000003AD58A0C59](this=0x01d803b0d481 <JSGlobal Object>,chunk=0x010e6094a299 
<String[9]: prototype>,original=0x021da8f29cd1 <Object map = 000001EC1636A009>)
2: SourceNode_walk [0000010FBDDA0F91] [E:clientmonaianode_modulessource-maplib...
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of 
memory
1: 00007FF645EEDD8A v8::internal::GCIdleTimeHandler::GCIdleTimeHandler+4506
2: 00007FF645EC8886 node::MakeCallback+4534
3: 00007FF645EC9200 node_module_register+2032
4: 00007FF6461E30DE v8::internal::FatalProcessOutOfMemory+846
5: 00007FF6461E300F v8::internal::FatalProcessOutOfMemory+639
6: 00007FF6463C9804 v8::internal::Heap::MaxHeapGrowingFactor+9620
7: 00007FF6463C07E6 v8::internal::ScavengeJob::operator=+24550
8: 00007FF6463BEE3C v8::internal::ScavengeJob::operator=+17980
9: 00007FF6463C7B87 v8::internal::Heap::MaxHeapGrowingFactor+2327
10: 00007FF6463C7C06 v8::internal::Heap::MaxHeapGrowingFactor+2454
11: 00007FF6464F1EA7 v8::internal::Factory::NewFillerObject+55
12: 00007FF64656F096 v8::internal::operator<<+73494
13: 0000003AD395C5C1
npm ERR! code ELIFECYCLE
npm ERR! errno 134
npm ERR! paytify@0.1.0 build: `react-scripts build`
npm ERR! Exit status 134
npm ERR!
npm ERR! Failed at the paytify@0.1.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!     C:Usersharoon tradersAppDataRoamingnpm-cache_logs2020-11-07T22_11_58_325Z- 
debug.log`

这些是我的依赖项:

`"dependencies": {
"@khanacademy/react-multi-select": "^0.3.3",
"@material-ui/core": "^4.8.0",
"@material-ui/icons": "^4.5.1",
"@material-ui/lab": "^4.0.0-alpha.44",
"@material-ui/styles": "^4.7.1",
"@stripe/react-stripe-js": "^1.1.2",
"@stripe/stripe-js": "^1.8.0",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
"browser-image-compression": "^1.0.11",
"chart.js": "^2.9.3",
"dotenv": "^8.2.0",
"emoji-mart": "^3.0.0",
"firebase": "^7.6.1",
"i18next": "^19.3.3",
"jquery": "^3.4.1",
"lodash": "^4.17.15",
"mic-recorder-to-mp3": "^2.2.2",
"moment": "^2.24.0",
"react": "^16.12.0",
"react-charts": "^2.0.0-beta.6",
"react-contenteditable": "^3.3.5",
"react-day-picker": "^7.4.8",
"react-dom": "^16.12.0",
"react-export-excel": "^0.5.3",
"react-geocode": "^0.2.1",
"react-google-autocomplete": "^1.1.2",
"react-google-maps": "^9.4.5",
"react-i18next": "^11.3.4",
"react-idle-timer": "^4.2.12",
"react-image-crop": "^8.5.0",
"react-phone-number-input": "^3.0.24",
"react-qr-reader": "^2.2.1",
"react-redux": "^7.1.3",
"react-router-dom": "^5.1.2",
"react-scripts": "^3.4.1",
"react-scroll": "^1.8.1",
"react-simple-timefield": "^3.0.0",
"react-to-print": "^2.7.0",
"react-toastify": "^6.0.8",
"redux": "^4.0.4",
"redux-persist": "^6.0.0",
"redux-thunk": "^2.3.0"
},`

注意:

我尝试了所有的解决方案,如npm cache clean --force、删除节点模块npm install/yarn install,甚至更新了react-scripts版本。

我通过在package.json"scripts"部分添加以下一行代码来解决问题。

"scripts": {"build": "react-scripts --expose-gc --max-old-space-size=8192 build",... ...}

https://stackoverflow.com/a/59983758/13129244

最新更新