2.6.10
https://github.com/greenpdx/opencv-vue
npm i opencv.js
adicione algumas linhas a main.js
import * as cv from 'opencv.js'
Vue.prototype.$cv = cv
e tente construir npm run build
Building for production...
DONE Compiled successfully
⠼ Building for production...
<--- Last few GCs --->
[12278:0x55a446ded250] 48764 ms: Mark-sweep 1336.7 (1441.2) -> 1321.7 (1441.2) MB, 875.5 / 0.0 ms (average mu = 0.184, current mu = 0.078) allocation failure scavenge might not succeed
[12278:0x55a446ded250] 49725 ms: Mark-sweep 1337.0 (1441.2) -> 1322.0 (1441.7) MB, 892.9 / 0.0 ms (average mu = 0.130, current mu = 0.071) allocation failure scavenge might not succeed
<--- JS stacktrace --->
==== JS stack trace =========================================
0: ExitFrame [pc: 0x13e4d8c4fc5d]
Security context: 0x266f3d81d9f1 <JSObject>
1: Sn(aka Sn) [0x169ed77ba971] [.../test0/node_modules/terser/dist/bundle.min.js:~1] [pc=0x13e4d93a6153](this=0x1ec95ca825b1 <undefined>,0x1ec95ca825b1 <undefined>)
2: /* anonymous */(aka /* anonymous */) [0xfa94c311551] [.../test0/node_modules/terser/dist/bundle.min.js:~1] [pc=0x13e4d93c1...
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
1: 0x55a445721761 node::Abort() [/usr/bin/node]
2: 0x55a445723255 node::OnFatalError(char const*, char const*) [/usr/bin/node]
3: 0x55a4458c9002 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/usr/bin/node]
4: 0x55a4458c925b v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/usr/bin/node]
5: 0x55a445c60573 [/usr/bin/node]
6: 0x55a445c606b4 [/usr/bin/node]
7: 0x55a445c70656 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/usr/bin/node]
8: 0x55a445c70ffe v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/usr/bin/node]
9: 0x55a445c73a1d v8::internal::Heap::AllocateRawWithLightRetry(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/usr/bin/node]
10: 0x55a445c73a72 v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/usr/bin/node]
11: 0x55a445c41418 v8::internal::Factory::AllocateRawArray(int, v8::internal::PretenureFlag) [/usr/bin/node]
12: 0x55a445c41934 v8::internal::Factory::NewFixedArrayWithFiller(v8::internal::Heap::RootListIndex, int, v8::internal::Object*, v8::internal::PretenureFlag) [/usr/bin/node]
13: 0x55a445c41a00 v8::internal::Handle<v8::internal::FixedArray> v8::internal::Factory::NewFixedArrayWithMap<v8::internal::FixedArray>(v8::internal::Heap::RootListIndex, int, v8::internal::PretenureFlag) [/usr/bin/node]
14: 0x55a445d7344c v8::internal::HashTable<v8::internal::NameDictionary, v8::internal::NameDictionaryShape>::New(v8::internal::Isolate*, int, v8::internal::PretenureFlag, v8::internal::MinimumCapacity) [/usr/bin/node]
15: 0x55a445d9539f v8::internal::BaseNameDictionary<v8::internal::NameDictionary, v8::internal::NameDictionaryShape>::EnsureCapacity(v8::internal::Isolate*, v8::internal::Handle<v8::internal::NameDictionary>, int) [/usr/bin/node]
16: 0x55a445d95409 v8::internal::Dictionary<v8::internal::NameDictionary, v8::internal::NameDictionaryShape>::Add(v8::internal::Isolate*, v8::internal::Handle<v8::internal::NameDictionary>, v8::internal::Handle<v8::internal::Name>, v8::internal::Handle<v8::internal::Object>, v8::internal::PropertyDetails, int*) [/usr/bin/node]
17: 0x55a445ed2fc4 v8::internal::Runtime_AddDictionaryProperty(int, v8::internal::Object**, v8::internal::Isolate*) [/usr/bin/node]
18: 0x13e4d8c4fc5d
⠦ Building for production...^C⏎
Do repositório do autor , não tenho resposta.
O problema vem daquele repo, não daqui, você não pode simplesmente abrir um fascículo aqui porque você não obteve uma resposta lá ...
Se você descobrir de onde vem o problema especificamente ou, melhor ainda, encontrar a solução, abra um novo problema com uma reprodução resumida (sem opencv)
@posva
O problema é devido ao grande tamanho do pacote, então é melhor você saber como aumentar o limite de memória
há um limite padrão estrito para o uso de memória no V8 de cerca de 1,7 GB, se você não aumentar manualmente.
node --max-old-space-size=4096 yourFile.js
como fazer isso em vue-cli?
 FEITO
apenas uma linha com a chave
NODE_OPTIONS=--max_old_space_size=4096 npm run build
Comentários muito úteis
apenas uma linha com a chave
NODE_OPTIONS=--max_old_space_size=4096 npm run build