美文网首页
vue+webstrom JavaScript heap out

vue+webstrom JavaScript heap out

作者: hsqin | 来源:发表于2020-10-20 17:16 被阅读0次

    开发过程中的问题描述:

    本地开发环境,添加新页面 或者 修改代码后,webstrom就自动终止npm run了,提示‘JavaScript heap out of memory’,如下:

    95% emittingFATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
    
     1: <--- Last few GCs --->
    
    [649:0x102801c00]  1135186 ms: Mark-sweep 1397.5 (1660.5) -> 1397.2 (1661.5) MB, 209.4 / 0.0 ms  allocation failure GC in old space requested
    [649:0x102801c00]  1135423 ms: Mark-sweep 1397.2 (1661.5) -> 1397.0 (1611.0) MB, 236.3 / 0.0 ms  last resort 
    [649:0x102801c00]  1135619 ms: Mark-sweep 1397.0 (1611.0) -> 1397.0 (1603.5) MB, 195.7 / 0.0 ms  last resort 
    <--- JS stacktrace --->
    
    ==== JS stack trace =========================================
    
    Security context: 0x875810a9891 <JS Object>
        1: fromString(aka fromString) [buffer.js:~254] [pc=0x1e506d458da3](this=0x1c279f202311 <undefined>,string=0x3eae49bc0f51 <Very long string[1607855]>,encoding=0x875810bd0e1 <String[4]: utf8>)
        2: new constructor(aka Buffer) [buffer.js:~120] [pc=0x1e506c2e4e6c](this=0x3eae49bc0f79 <a Buffer with map 0x20174a1656d1>,arg=0x3eae49bc0f51 <Very long string[1607855]>,encodingOrOffset=0x875810bd0e...
    
    node::Abort() [/usr/local/bin/node]
     2: node::FatalException(v8::Isolate*, v8::Local<v8::Value>, v8::Local<v8::Message>) [/usr/local/bin/node]
     3: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [/usr/local/bin/node]
     4: v8::internal::Factory::NewRawTwoByteString(int, v8::internal::PretenureFlag) [/usr/local/bin/node]
     5: v8::internal::String::SlowFlatten(v8::internal::Handle<v8::internal::ConsString>, v8::internal::PretenureFlag) [/usr/local/bin/node]
     6: v8::String::WriteUtf8(char*, int, int*, int) const [/usr/local/bin/node]
     7: node::StringBytes::Write(v8::Isolate*, char*, unsigned long, v8::Local<v8::Value>, node::encoding, int*) [/usr/local/bin/node]
     8: node::Buffer::New(v8::Isolate*, v8::Local<v8::String>, node::encoding) [/usr/local/bin/node]
     9: node::Buffer::(anonymous namespace)::CreateFromString(v8::FunctionCallbackInfo<v8::Value> const&) [/usr/local/bin/node]
    10: 0x1e506c40f9a5
    
    Process finished with exit code 134 (interrupted by signal 6: SIGABRT)
    

    重点及解决方案

    • 本地开发环境
    • 使用的版本 vue@2.5.2
    • package.json 中 dev的原始配置如下
    "scripts": {
        "dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js --host 192.168.1.93",
        "start": "npm run dev",
        "build": "node build/build.js",
        "pro": "node --max_old_space_size=9000 build/build.js "
      },
    
    • 最终解决方案为 修改package.json:注意,修改的是dev ↓↓
    "scripts": {
        "dev": "node --max-old-space-size=4096 ./node_modules/.bin/webpack-dev-server --inline --progress --config build/webpack.dev.conf.js --host 192.168.1.93",
        "start": "npm run dev",
        "build": "node build/build.js",
        "pro": "node --max_old_space_size=9000 build/build.js "
      },
    

    相关文章

      网友评论

          本文标题:vue+webstrom JavaScript heap out

          本文链接:https://www.haomeiwen.com/subject/ytidmktx.html