justadudewhohacks / opencv4nodejs

Nodejs bindings to OpenCV 3 and OpenCV 4
MIT License
4.96k stars 827 forks source link

React JS project Error: TypeError: Cannot read property '_handle' of undefined., stream isn undefined. #615

Open farshidbakh opened 5 years ago

farshidbakh commented 5 years ago

This is the error I am getting, I am using OpenCV@3 and "opencv4nodejs": "^5.1.0".

What am I missing? I would greatly appreciate your help.

There are the error, I am getting. It seems that "stream" is not defined.

Error (below):

TypeError: ### Cannot read property '_handle' of undefined (anonymous function) src/simpleui/frontend/node_modules/set-blocking/index.js:3 1 | module.exports = function (blocking) { 2 | [process.stdout, process.stderr].forEach(function (stream) {

3 | if (stream._handle && stream.isTTY && typeof stream._handle.setBlocking === 'function') { 4 | stream._handle.setBlocking(blocking) 5 | } 6 | }) View compiled ./node_modules/set-blocking/index.js.module.exports src/simpleui/frontend/node_modules/set-blocking/index.js:2 1 | module.exports = function (blocking) { 2 | [process.stdout, process.stderr].forEach(function (stream) { 3 | if (stream._handle && stream.isTTY && typeof stream._handle.setBlocking === 'function') { 4 | stream._handle.setBlocking(blocking) 5 | } View compiled (anonymous function) src/simpleui/frontend/node_modules/npmlog/log.js:11 8 | var setBlocking = require('set-blocking') 9 | var consoleControl = require('console-control-strings') 10 | 11 | setBlocking(true) 12 | var stream = process.stderr 13 | Object.defineProperty(log, 'stream', { 14 | set: function (newStream) { View compiled ./node_modules/npmlog/log.js http://localhost:3000/static/js/bundle.js:180504:30 webpack_require src/simpleui/frontend/webpack/bootstrap 5a9939d6c8d44863ebcb:678 675 | }; 676 | 677 | // Execute the module function 678 | modules[moduleId].call(module.exports, module, module.exports, hotCreateRequire(moduleId)); 679 | 680 | // Flag the module as loaded 681 | module.l = true; View compiled fn src/simpleui/frontend/webpack/bootstrap 5a9939d6c8d44863ebcb:88 85 | console.warn("[HMR] unexpected require(" + request + ") from disposed module " + moduleId); 86 | hotCurrentParents = []; 87 | } 88 | return webpack_require(request); 89 | }; 90 | var ObjectFactory = function ObjectFactory(name) { 91 | return { View compiled (anonymous function) src/simpleui/frontend/node_modules/opencv-build/build/utils.js:41 38 | var child_process = require("child_process"); 39 | var fs = require("fs"); 40 | var path = require("path"); 41 | var log = require('npmlog'); 42 | function exec(cmd, options) { 43 | log.silly('install', 'executing:', cmd); 44 | return new Promise(function (resolve, reject) { View compiled ./node_modules/opencv-build/build/utils.js http://localhost:3000/static/js/bundle.js:181120:30 webpack_require src/simpleui/frontend/webpack/bootstrap 5a9939d6c8d44863ebcb:678 675 | }; 676 | 677 | // Execute the module function 678 | modules[moduleId].call(module.exports, module, module.exports, hotCreateRequire(moduleId)); 679 | 680 | // Flag the module as loaded 681 | module.l = true; View compiled fn src/simpleui/frontend/webpack/bootstrap 5a9939d6c8d44863ebcb:88 85 | console.warn("[HMR] unexpected require(" + request + ") from disposed module " + moduleId); 86 | hotCurrentParents = []; 87 | } 88 | return webpack_require(request); 89 | }; 90 | var ObjectFactory = function ObjectFactory(name) { 91 | return { View compiled (anonymous function) src/simpleui/frontend/node_modules/opencv-build/build/dirs.js:4 1 | "use strict"; 2 | Object.defineProperty(exports, "esModule", { value: true }); 3 | var path = require("path"); 4 | var utils_1 = require("./utils"); 5 | var rootDir = path.resolve(__dirname, '../'); 6 | var opencvRoot = path.join(rootDir, 'opencv'); 7 | var opencvSrc = path.join(opencvRoot, 'opencv'); View compiled ./node_modules/opencv-build/build/dirs.js http://localhost:3000/static/js/bundle.js:180758:30 webpack_require src/simpleui/frontend/webpack/bootstrap 5a9939d6c8d44863ebcb:678 675 | }; 676 | 677 | // Execute the module function 678 | modules[moduleId].call(module.exports, module, module.exports, hotCreateRequire(moduleId)); 679 | 680 | // Flag the module as loaded 681 | module.l = true; View compiled fn src/simpleui/frontend/webpack/bootstrap 5a9939d6c8d44863ebcb:88 85 | console.warn("[HMR] unexpected require(" + request + ") from disposed module " + moduleId); 86 | hotCurrentParents = []; 87 | } 88 | return webpack_require(request); 89 | }; 90 | var ObjectFactory = function ObjectFactory(name) { 91 | return { View compiled ./node_modules/opencv-build/build/constants.js src/simpleui/frontend/node_modules/opencv-build/build/constants.js:3 1 | "use strict"; 2 | Object.defineProperty(exports, "esModule", { value: true }); 3 | var dirs_1 = require("./dirs"); 4 | exports.OPENCV_CONTRIB_ARCHIVE = 'https://github.com/opencv/opencv_contrib/archive/3.4.6.tar.gz'; 5 | exports.opencvRepoUrl = 'https://github.com/opencv/opencv.git'; 6 | exports.opencvContribRepoUrl = 'https://github.com/opencv/opencv_contrib.git'; View compiled webpack_require src/simpleui/frontend/webpack/bootstrap 5a9939d6c8d44863ebcb:678 675 | }; 676 | 677 | // Execute the module function 678 | modules[moduleId].call(module.exports, module, module.exports, hotCreateRequire(moduleId)); 679 | 680 | // Flag the module as loaded 681 | module.l = true; View compiled fn src/simpleui/frontend/webpack/bootstrap 5a9939d6c8d44863ebcb:88 85 | console.warn("[HMR] unexpected require(" + request + ") from disposed module " + moduleId); 86 | hotCurrentParents = []; 87 | } 88 | return webpack_require(request); 89 | }; 90 | var ObjectFactory = function ObjectFactory(name) { 91 | return { View compiled ./node_modules/opencv-build/build/index.js src/simpleui/frontend/node_modules/opencv-build/build/index.js:5 2 | Object.defineProperty(exports, "esModule", { value: true }); 3 | var fs = require("fs"); 4 | var path = require("path"); 5 | var constants_1 = require("./constants"); 6 | var dirs_1 = require("./dirs"); 7 | var getLibsFactory_1 = require("./getLibsFactory"); 8 | var utils_1 = require("./utils"); View compiled webpack_require src/simpleui/frontend/webpack/bootstrap 5a9939d6c8d44863ebcb:678 675 | }; 676 | 677 | // Execute the module function 678 | modules[moduleId].call(module.exports, module, module.exports, hotCreateRequire(moduleId)); 679 | 680 | // Flag the module as loaded 681 | module.l = true; View compiled fn src/simpleui/frontend/webpack/bootstrap 5a9939d6c8d44863ebcb:88 85 | console.warn("[HMR] unexpected require(" + request + ") from disposed module " + moduleId); 86 | hotCurrentParents = []; 87 | } 88 | return webpack_require(request); 89 | }; 90 | var ObjectFactory = function ObjectFactory(name) { 91 | return { View compiled (anonymous function) src/simpleui/frontend/node_modules/opencv4nodejs/lib/cv.js:2 1 | const path = require('path'); 2 | const opencvBuild = require('opencv-build'); 3 | const { resolvePath } = require('./commons'); 4 | 5 | // ensure binaries are added to path on windows View compiled ./node_modules/opencv4nodejs/lib/cv.js http://localhost:3000/static/js/bundle.js:181231:30 webpack_require src/simpleui/frontend/webpack/bootstrap 5a9939d6c8d44863ebcb:678 675 | }; 676 | 677 | // Execute the module function 678 | modules[moduleId].call(module.exports, module, module.exports, hotCreateRequire(moduleId)); 679 | 680 | // Flag the module as loaded 681 | module.l = true; View compiled fn src/simpleui/frontend/webpack/bootstrap 5a9939d6c8d44863ebcb:88 85 | console.warn("[HMR] unexpected require(" + request + ") from disposed module " + moduleId); 86 | hotCurrentParents = []; 87 | } 88 | return webpack_require(request); 89 | }; 90 | var ObjectFactory = function ObjectFactory(name) { 91 | return { View compiled (anonymous function) src/simpleui/frontend/node_modules/opencv4nodejs/lib/opencv4nodejs.js:11 8 | && global.window && global.window.process && global.window.process.type 9 | && global.navigator && ((global.navigator.userAgent || '').toLowerCase().indexOf(' electron/') > -1) 10 | 11 | let cv = isElectronWebpack ? require('../build/Release/opencv4nodejs.node') : require('./cv') 12 | 13 | // promisify async methods 14 | cv = promisify(cv); View compiled ./node_modules/opencv4nodejs/lib/opencv4nodejs.js http://localhost:3000/static/js/bundle.js:181260:30 webpack_require src/simpleui/frontend/webpack/bootstrap 5a9939d6c8d44863ebcb:678 675 | }; 676 | 677 | // Execute the module function 678 | modules[moduleId].call(module.exports, module, module.exports, hotCreateRequire(moduleId)); 679 | 680 | // Flag the module as loaded 681 | module.l = true; View compiled fn src/simpleui/frontend/webpack/bootstrap 5a9939d6c8d44863ebcb:88 85 | console.warn("[HMR] unexpected require(" + request + ") from disposed module " + moduleId); 86 | hotCurrentParents = []; 87 | } 88 | return webpack_require(request); 89 | }; 90 | var ObjectFactory = function ObjectFactory(name) { 91 | return { View compiled ./src/components/views/OpenCVView.js http://localhost:3000/static/js/bundle.js:315820:73 webpack_require src/simpleui/frontend/webpack/bootstrap 5a9939d6c8d44863ebcb:678 675 | }; 676 | 677 | // Execute the module function 678 | modules[moduleId].call(module.exports, module, module.exports, hotCreateRequire(moduleId)); 679 | 680 | // Flag the module as loaded 681 | module.l = true; View compiled fn src/simpleui/frontend/webpack/bootstrap 5a9939d6c8d44863ebcb:88 85 | console.warn("[HMR] unexpected require(" + request + ") from disposed module " + moduleId); 86 | hotCurrentParents = []; 87 | } 88 | return webpack_require(request); 89 | }; 90 | var ObjectFactory = function ObjectFactory(name) { 91 | return { View compiled ./src/components/views/AppView.js http://localhost:3000/static/js/bundle.js:307110:71 webpack_require src/simpleui/frontend/webpack/bootstrap 5a9939d6c8d44863ebcb:678 675 | }; 676 | 677 | // Execute the module function 678 | modules[moduleId].call(module.exports, module, module.exports, hotCreateRequire(moduleId)); 679 | 680 | // Flag the module as loaded 681 | module.l = true; View compiled fn src/simpleui/frontend/webpack/bootstrap 5a9939d6c8d44863ebcb:88 85 | console.warn("[HMR] unexpected require(" + request + ") from disposed module " + moduleId); 86 | hotCurrentParents = []; 87 | } 88 | return webpack_require(request); 89 | }; 90 | var ObjectFactory = function ObjectFactory(name) { 91 | return { View compiled ./src/components/views/MainView.js http://localhost:3000/static/js/bundle.js:315574:67 webpack_require src/simpleui/frontend/webpack/bootstrap 5a9939d6c8d44863ebcb:678 675 | }; 676 | 677 | // Execute the module function 678 | modules[moduleId].call(module.exports, module, module.exports, hotCreateRequire(moduleId)); 679 | 680 | // Flag the module as loaded 681 | module.l = true; View compiled fn src/simpleui/frontend/webpack/bootstrap 5a9939d6c8d44863ebcb:88 85 | console.warn("[HMR] unexpected require(" + request + ") from disposed module " + moduleId); 86 | hotCurrentParents = []; 87 | } 88 | return webpack_require(request); 89 | }; 90 | var ObjectFactory = function ObjectFactory(name) { 91 | return { View compiled ./src/App.js http://localhost:3000/static/js/bundle.js:304713:85 webpack_require src/simpleui/frontend/webpack/bootstrap 5a9939d6c8d44863ebcb:678 675 | }; 676 | 677 | // Execute the module function 678 | modules[moduleId].call(module.exports, module, module.exports, hotCreateRequire(moduleId)); 679 | 680 | // Flag the module as loaded 681 | module.l = true; View compiled fn src/simpleui/frontend/webpack/bootstrap 5a9939d6c8d44863ebcb:88 85 | console.warn("[HMR] unexpected require(" + request + ") from disposed module " + moduleId); 86 | hotCurrentParents = []; 87 | } 88 | return webpack_require(request); 89 | }; 90 | var ObjectFactory = function ObjectFactory(name) { 91 | return { View compiled ./src/index.js http://localhost:3000/static/js/bundle.js:324783:63 webpack_require src/simpleui/frontend/webpack/bootstrap 5a9939d6c8d44863ebcb:678 675 | }; 676 | 677 | // Execute the module function 678 | modules[moduleId].call(module.exports, module, module.exports, hotCreateRequire(moduleId)); 679 | 680 | // Flag the module as loaded 681 | module.l = true; View compiled fn src/simpleui/frontend/webpack/bootstrap 5a9939d6c8d44863ebcb:88 85 | console.warn("[HMR] unexpected require(" + request + ") from disposed module " + moduleId); 86 | hotCurrentParents = []; 87 | } 88 | return webpack_require(request); 89 | }; 90 | var ObjectFactory = function ObjectFactory(name) { 91 | return { View compiled 0 http://localhost:3000/static/js/bundle.js:329917:18 webpack_require src/simpleui/frontend/webpack/bootstrap 5a9939d6c8d44863ebcb:678 675 | }; 676 | 677 | // Execute the module function 678 | modules[moduleId].call(module.exports, module, module.exports, hotCreateRequire(moduleId)); 679 | 680 | // Flag the module as loaded 681 | module.l = true; View compiled (anonymous function) src/simpleui/frontend/webpack/bootstrap 5a9939d6c8d44863ebcb:724 721 | webpack_require.h = function() { return hotCurrentHash; }; 722 | 723 | // Load entry module and return exports 724 | return hotCreateRequire(0)(webpack_require__.s = 0); 725 | 726 | 727 | View compiled (anonymous function) http://localhost:3000/static/js/bundle.js:728:10 This screen is visible only in development. It will not appear if the app crashes in production. Open your browser’s developer console to further inspect this error.

*OpenCV 3

With OpenCV-contrib? (extra modules): yes/no? NO

OS: MacOSX?

nwheatle commented 5 years ago

Did you figure it out? I have the same problem on Ubuntu in React App. Do you have any ideas of what is wrong yet?

farshidbakh commented 5 years ago

No, I have no idea, and I still have the problem. I am hoping someone has a solution for this problem. Thanks, and good luck.

nwheatle commented 5 years ago

I posted the question on stackoverflow https://stackoverflow.com/questions/57836463/importing-opencv4nodejs-to-react-app-js-throws-typeerror hopefully someone there can help.

farshidbakh commented 5 years ago

Thanks a lot. Hopefully!

nwheatle commented 5 years ago

I got a hint from another developer that opencv4nodejs is probably supposed to be used server-side /back-end -- thus the nodejs in the name. If you used create-react-app to make your react app, then there is no server. I'm going to look into making my react app with Next.js so that it has a server, and then maybe the module will work. I'll kit.

shailjaa commented 4 years ago

I am getting the same error and I still can't find a solution.

s3q commented 3 years ago

me too 😕