opencv4nodejs
opencv4nodejs copied to clipboard
str.replace is not a function
Macos OpenCV installed with brew
Node.js v20.11.1 OpenCV 4.9.0_4
package.json
"dependencies": {
"@nestjs/common": "^10.0.0",
"@nestjs/core": "^10.0.0",
"@nestjs/platform-express": "^10.0.0",
"@nestjs/swagger": "^7.3.0",
"@serialport/parser-readline": "^12.0.0",
"@u4/opencv-build": "^1.0.0",
"@u4/opencv4nodejs": "^7.0.0",
"axios": "^1.6.7",
"axios-retry": "^4.0.0",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.1",
"reflect-metadata": "^0.1.13",
"rxjs": "^7.8.1",
"serialport": "^12.0.0",
"tesseract.js": "^5.0.5"
},
"opencv4nodejs": {
"disableAutoBuild": 1,
"opencvIncludeDir": "/opt/homebrew/Cellar/opencv/4.9.0_4/include/opencv4/",
"opencvLibDir": "/opt/homebrew/Cellar/opencv/4.9.0_4/lib/",
"opencvBinDir": "/opt/homebrew/Cellar/opencv/4.9.0_4/bin/"
}
info config found opencv4nodejs section in /Users/alexandrsmirnov/Work/lombard-white/nestjs-lombard-terminal/package.json
info init no_autobuild is set.
info init
info applyEnvsFromPackageJson the following opencv4nodejs environment variables are set in the package.json:
/Users/alexandrsmirnov/Work/lombard-white/nestjs-lombard-terminal/node_modules/@u4/opencv-build/script/deps/jsr.io/@std/fmt/0.223.0/colors.js:119
? `${code.open}${str.replace(code.regexp, code.open)}${code.close}`
^
TypeError: str.replace is not a function
at run (/Users/alexandrsmirnov/Work/lombard-white/nestjs-lombard-terminal/node_modules/@u4/opencv-build/script/deps/jsr.io/@std/fmt/0.223.0/colors.js:119:30)
at Object.green (/Users/alexandrsmirnov/Work/lombard-white/nestjs-lombard-terminal/node_modules/@u4/opencv-build/script/deps/jsr.io/@std/fmt/0.223.0/colors.js:210:12)
at formatNumber (/Users/alexandrsmirnov/Work/lombard-white/nestjs-lombard-terminal/node_modules/@u4/opencv-build/script/src/utils.js:67:43)
at /Users/alexandrsmirnov/Work/lombard-white/nestjs-lombard-terminal/node_modules/@u4/opencv-build/script/src/OpenCVBuildEnv.js:396:161
at Array.forEach (<anonymous>)
at new OpenCVBuildEnv (/Users/alexandrsmirnov/Work/lombard-white/nestjs-lombard-terminal/node_modules/@u4/opencv-build/script/src/OpenCVBuildEnv.js:396:21)
at new OpenCVBuilder (/Users/alexandrsmirnov/Work/lombard-white/nestjs-lombard-terminal/node_modules/@u4/opencv-build/script/src/OpenCVBuilder.js:75:24)
at getOpenCV (/Users/alexandrsmirnov/Work/lombard-white/nestjs-lombard-terminal/node_modules/@u4/opencv4nodejs/cjs/lib/cvloader.js:40:21)
at loadOpenCV (/Users/alexandrsmirnov/Work/lombard-white/nestjs-lombard-terminal/node_modules/@u4/opencv4nodejs/cjs/lib/opencv4nodejs.js:36:48)
at Object.<anonymous> (/Users/alexandrsmirnov/Work/lombard-white/nestjs-lombard-terminal/node_modules/@u4/opencv4nodejs/cjs/lib/opencv4nodejs.js:58:14)
I got to the bottom of this by researching #134, so I'd like to comment here as well.
The cause is that a boolean is passed to @std/fmt/0.223.0/colors.js L117.
function run(str, code) {
console.log(`★str: ${str}`);
return enabled
? `${code.open}${str.replace(code.regexp, code.open)}${code.close}`
: str;
}
★str: %s
★str: %s
info config found opencv4nodejs section in C:\Work\Instore\workspace\_survey\cv-crash-case_fix\package.json
info envAutodetect autodetect 0 changes
info init no_autobuild is set.
info init
info applyEnvsFromPackageJson the following opencv4nodejs environment variables are set in the package.json:
★str: autoBuildOpencvVersion
★str: autoBuildOpencvVersion
★str: 4.9.0
★str: 4.9.0
info applyEnvsFromPackageJson autoBuildOpencvVersion: 4.9.0
★str: autoBuildFlags
★str: autoBuildFlags
★str: -DBUILD_LIST=core,imgproc,imgcodecs,videoio,highgui
★str: -DBUILD_LIST=core,imgproc,imgcodecs,videoio,highgui
info applyEnvsFromPackageJson autoBuildFlags: -DBUILD_LIST=core,imgproc,imgcodecs,videoio,highgui
★str: autoBuildWithoutContrib
★str: autoBuildWithoutContrib
★str: true
info init no_autobuild is set.
info init
info applyEnvsFromPackageJson the following opencv4nodejs environment variables are set in the package.json:
★str: autoBuildOpencvVersion
★str: autoBuildOpencvVersion
★str: 4.9.0
★str: 4.9.0
info applyEnvsFromPackageJson autoBuildOpencvVersion: 4.9.0
★str: autoBuildFlags
★str: autoBuildFlags
★str: -DBUILD_LIST=core,imgproc,imgcodecs,videoio,highgui
★str: -DBUILD_LIST=core,imgproc,imgcodecs,videoio,highgui
info applyEnvsFromPackageJson autoBuildFlags: -DBUILD_LIST=core,imgproc,imgcodecs,videoio,highgui
★str: autoBuildWithoutContrib
★str: autoBuildWithoutContrib
★str: true
C:\Work\Instore\workspace\_survey\cv-crash-case_fix\node_modules\@u4\opencv-build\script\deps\jsr.io\@std\fmt\0.223.0\colors.js:120
? `${code.open}${str.replace(code.regexp, code.open)}${code.close}`
^
TypeError: str.replace is not a function
function run(str, code) {
console.log(`★str: ${str}`);
return enabled
? `${code.open}${str.replace(code.regexp, code.open)}${code.close}`
: str;
}
is not part of the project.
by the way, I know ths issue: I use to replace npm:picocolors by deno @std/fmt/colors but the deno version only accept string.