vue-cli搭建的项目,之前一直是用npm run dev启动的项目,但是最近不能启动了,报错如下:

<--- Last few GCs --->
[7030:0x102802400]    90535 ms: Mark-sweep 1412.5 (1534.9) -> 1412.1 (1538.9) MB, 1093.9 / 2.2 ms  allocation failure GC in old space requested
[7030:0x102802400]    91593 ms: Mark-sweep 1412.1 (1538.9) -> 1412.0 (1507.9) MB, 1057.5 / 2.3 ms  last resort GC in old space requested
[7030:0x102802400]    92632 ms: Mark-sweep 1412.0 (1507.9) -> 1412.0 (1507.9) MB, 1039.4 / 2.1 ms  last resort GC in old space requested
<--- JS stacktrace --->
==== JS stack trace =========================================
Security context: 0x3aa64faa54d9 <JSObject>
    1: set(this=0x3aa6e5392fe1 <Map map = 0x3aa624f848d9>,0x3aa6ae84a549 <String[194]: /Users/Hanger/GitHub/myjs/node_modules/babel-plugin-transform-es2015-classes/node_modules/babel-helper-function-name/node_modules/babel-template/node_modules/babel-runtime/helpers/createClass.js>,0x3aa6ae84a651 <JSArray[1]>)
    2: /* anonymous */ [/Users/Hanger/GitHub/myjs/node_modules/_webpack@2.7.0@webpack/...
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: node::Abort() [/usr/local/bin/node]
 2: node::OnFatalError(char const*, char const*) [/usr/local/bin/node]
 3: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [/usr/local/bin/node]
 4: v8::internal::Factory::NewFixedArray(int, v8::internal::PretenureFlag) [/usr/local/bin/node]
 5: v8::internal::OrderedHashTable<v8::internal::OrderedHashMap, 2>::Rehash(v8::internal::Handle<v8::internal::OrderedHashMap>, int) [/usr/local/bin/node]
 6: v8::internal::Runtime_MapGrow(int, v8::internal::Object**, v8::internal::Isolate*) [/usr/local/bin/node]
 7: 0x2ecd2d1042fd
 8: 0x2ecd2d1b251e

试着运行了其他的用vue-cli搭建的项目,也有这个问题,我代码都没动过,突然就不能运行了。
网上搜索过解决方法,然后在package.json里做了如下修改

"scripts": {
    "dev": "node --max_old_space_size=8000 build/dev-server.js",
 },

但是依然没有作用,求大神告知解决方法,十分感谢!


···回复:

自己代码逻辑有问题


···回复:

内存超出,试着修改一下最大的内存。

node --max-old-space-size=4096 app

···回复:

估计是无穷递归了, 查查调用栈


···回复:

关于vue-cli2以及vue-cli3的内存溢出解决办法,详情解决办法在这里。
https://blog.csdn.net/win7583…

Scroll Up