最近運行vue項目時出現(xiàn)了內存溢出的問題
<--- Last few GCs --->
allocaca[77653:0x102523000] 26045 ms: Mark-sweep 1400.7 (1419.8) -> 1400.6 (1421.3) MB,
1162.2 / 0.0 ms (+ 0.0 ms in 32 steps since start of marking, biggest step 0.0 ms, walltime since start of marking 1171 ms) (average mu = 0.121, current mu = 0.008)
alloca[77653:0x102523000] 27509 ms: Mark-sweep 1402.5 (1421.3) -> 1402.4 (1423.3) MB,
1457.6 / 0.0 ms (+ 0.0 ms in 31 steps since start of marking, biggest step 0.0 ms, walltime since start of marking 1464 ms) (average mu = 0.059, current mu = 0.004)
<--- JS stacktrace --->
==== JS stack trace =========================================
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
面向搜索引擎解決問題一直是我們最常用的辦法,得到的解決方案無非是安裝插件:
npm install -g increase-memory-limit cross-env
在自己項目的package.json中配置腳本命令:
"scripts": {
"fix-memory-limit": "cross-env LIMIT=8048 increase-memory-limit",
}
運行腳本
npm run fix-memory-limit
然后啟動項目服務
npm run serve
信心滿滿,然后嘿,又報錯了
/Users/xxx/Documents/project/app/node_modules/@vue/cli-service/bin/vue-cli-service.js:4
const requiredVersion = require('../package.json').engines.node --max-old-space-size=8048
SyntaxError: Unexpected identifier
意思是不識別--max-old...這個標識符,然后繼續(xù)面向搜索引擎,說是要去掉package.json中的--max-old-space-size=8048就行了。
但是
我的package.json里沒有--max-old-space-size=8048啊,這我怎么刪。沒有啊~~~
與bug撕摸了很久,終于搜到一個前輩指點迷津。
到node_module中找到@vue模塊在cli-service目錄中找到vue-cli-service.js文件 刪除--max-old-space-size=8048
我尼瑪,真的哎,這時候我再仔細看最后一次報錯里的第一行,已經(jīng)指出了報錯文件的路徑。暴汗?。。?/p>