美文网首页
vue 项目 sudo cnpm run build打包报错 I

vue 项目 sudo cnpm run build打包报错 I

作者: CoderZb | 来源:发表于2022-01-21 20:32 被阅读0次

    报错内容如下:

    MrBin:agentChannelBackground zhangbin$ sudo cnpm run build
    Password:
    
    > fybcbackground@1.0.0 build /Users/zhangbin/Desktop/feiyang/agentChannelBackground
    > node build/build.js
    
    ⠹ building for production...
    <--- Last few GCs --->
    
    [65091:0x102808000]   185100 ms: Mark-sweep 1383.4 (1448.1) -> 1377.9 (1453.6) MB, 745.7 / 0.0 ms  (average mu = 0.117, current mu = 0.024) allocation failure scavenge might not succeed
    [65091:0x102808000]   186014 ms: Mark-sweep 1388.5 (1453.6) -> 1382.9 (1435.6) MB, 894.1 / 0.0 ms  (+ 0.1 ms in 169 steps since start of marking, biggest step 0.0 ms, walltime since start of marking 913 ms) (average mu = 0.064, current mu = 0.021) allocat
    
    <--- JS stacktrace --->
    
    ==== JS stack trace =========================================
    
        0: ExitFrame [pc: 0x46b20d5be3d]
        1: StubFrame [pc: 0x46b20d20573]
    Security context: 0x0d7c0911e6e9 <JSObject>
        2: /* anonymous */(aka /* anonymous */) [0xd7cdd324041] [/Users/zhangbin/Desktop/feiyang/agentChannelBackground/node_modules/_webpack-sources@1.4.3@webpack-sources/lib/applySourceMap.js:~58] [pc=0x46b22a5f810](this=0x0d7c221026f1 <undefined>,chunk=0x0d7cbe529df1 <String[13]: "lineStyle"),>,middleMapping=0x0d7cdfe52159 ...
    
    FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
     1: 0x10003d035 node::Abort() [/usr/local/bin/node]
     2: 0x10003d23f node::OnFatalError(char const*, char const*) [/usr/local/bin/node]
     3: 0x1001b8e15 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
     4: 0x100586d72 v8::internal::Heap::FatalProcessOutOfMemory(char const*) [/usr/local/bin/node]
     5: 0x100589845 v8::internal::Heap::CheckIneffectiveMarkCompact(unsigned long, double) [/usr/local/bin/node]
     6: 0x1005856ef v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/usr/local/bin/node]
     7: 0x1005838c4 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/usr/local/bin/node]
     8: 0x10059015c v8::internal::Heap::AllocateRawWithLigthRetry(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/usr/local/bin/node]
     9: 0x1005901df v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/usr/local/bin/node]
    10: 0x10057557e v8::internal::Handle<v8::internal::String> v8::internal::Factory::AllocateInternalizedStringImpl<false, v8::internal::Handle<v8::internal::String> >(v8::internal::Handle<v8::internal::String>, int, unsigned int) [/usr/local/bin/node]
    11: 0x1006d91d5 v8::internal::InternalizedStringKey::AsHandle(v8::internal::Isolate*) [/usr/local/bin/node]
    12: 0x1006c2180 v8::internal::StringTable::AddKeyNoResize(v8::internal::Isolate*, v8::internal::StringTableKey*) [/usr/local/bin/node]
    13: 0x1006c1b20 v8::internal::StringTable::LookupString(v8::internal::Isolate*, v8::internal::Handle<v8::internal::String>) [/usr/local/bin/node]
    14: 0x1001edefa v8::internal::LookupIterator::PropertyOrElement(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Name>, v8::internal::Handle<v8::internal::JSReceiver>, v8::internal::LookupIterator::Configuration) [/usr/local/bin/node]
    15: 0x100809c18 v8::internal::Runtime_HasProperty(int, v8::internal::Object**, v8::internal::Isolate*) [/usr/local/bin/node]
    16: 0x46b20d5be3d 
    MrBin:agentChannelBackground zhangbin$ 
    

    解决办法

    package.json 增加 --max_old_space_size=8192

    "scripts": {
        "dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
        "start": "npm run dev",
        "lint": "eslint --ext .js,.vue src",
        "build": "node  build/build.js"
      },
    

    改为

    "scripts": {
        "dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
        "start": "npm run dev",
        "lint": "eslint --ext .js,.vue src",
        "build": "node --max_old_space_size=8192 build/build.js"
      },
    

    相关文章

      网友评论

          本文标题:vue 项目 sudo cnpm run build打包报错 I

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