OpenCV: Library not loaded: libjpeg.8.dylib - node.js

This error with OpenCV (I'm trying to use Node + OpenCV - as in node-opencv) has been driving me crazy. I've looked at many answers on StackOverflow or otherwise, and I think this could be a problem with the upgraded Homebrew or maybe with OpenCV. Unless it is a problem with the way I imported OpenCV.
Does anyone understand this/know what to do?
module.js:598
return process.dlopen(module, path._makeLong(filename));
^
Error: dlopen(/Users/Joe/SRS/node_modules/opencv/build/opencv/v6.0.0/Release/node-v51-darw
in-x64/opencv.node, 1): Library not loaded: /usr/local/opt/jpeg/lib/libjpeg.8.dylib
Referenced from: /usr/local/opt/opencv/lib/libopencv_highgui.2.4.dylib
Reason: image not found
at Object.Module._extensions..node (module.js:598:18)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/Users/Joe/SRS/node_modules/opencv/lib/bindings.js:4:15)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)

I was getting the same error and reinstalling Open CV fixed it. I ran
brew reinstall --build-from-source opencv.

Related

Node.js error Error: Cannot find module 'datejs'

When datejs is installed using npm and when a script (below) is executed, the following error is obtained:
Error: Cannot find module 'datejs'
at Function._resolveFilename (module.js:334:11)
at Function._load (module.js:279:25)
at Module.require (module.js:357:17)
at require (module.js:368:17)
datejs module exists under correct node_modules.Thanks in advance.
Try require('./node_modules/datejs/index.js');

How do I tell a native node.js extension where to find (the right) libstdc++?

I’m installing scrypt (https://www.npmjs.com/package/scrypt) from npm. The installation involves a node-gyp build step that builds a native node.js extension. When I then start my app, it fails with the following error:
node index.js
module.js:568
return process.dlopen(module, path._makeLong(filename));
^
Error: /package/host/localhost/gcc-4/lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /home/xxxx/xxxx/node_modules/scrypt/build/Release/scrypt.node)
at Error (native)
at Object.Module._extensions..node (module.js:568:18)
at Module.load (module.js:456:32)
at tryModuleLoad (module.js:415:12)
at Function.Module._load (module.js:407:3)
at Module.require (module.js:466:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/home/xxxx/xxxx/node_modules/scrypt/index.js:3:20)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:456:32)
at tryModuleLoad (module.js:415:12)
at Function.Module._load (module.js:407:3)
at Module.require (module.js:466:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/home/xxxx/xxxx/node_modules/unfun-cms/lib/utils/password.js:3:16)
which is not so surprising, because
[xxxx#xxxx nodeapp]$ strings /package/host/localhost/gcc-4/lib64/libstdc++.so.6 | grep "GLIBCXX_3\.4\.21"
[xxxx#xxxx nodeapp]$
while
[xxxx#xxxx nodeapp]$ strings /package/host/localhost/gcc-5/lib64/libstdc++.so.6 | grep "GLIBCXX_3\.4\.21"
GLIBCXX_3.4.21
[xxxx#xxxx nodeapp]$
I have
export PATH=/package/host/localhost/gcc-5/bin:$PATH
export LD_LIBRARY_PATH=/package/host/localhost/gcc-5/lib64:$LD_LIBRARY_PATH
in my .bashrc, and gcc --version shows 5.2.0 correctly, so I assume these settings are alright.
So the question is, how do I tell scrypt the path to the correct libstdc++.so.6, namely the one at /package/host/localhost/gcc-5/lib64/libstdc++.so.6? (And why does it even get it wrong?)
EDIT:
This is a CentOS machine. I’m using node.js version 6.1.0, npm version 3.8.6, and I’m trying to install scrypt version 6.0.3, which is the latest version at the time of this writing.
EDIT 2:
I tried to statically link the library by editing node_modules/scrypt/binding.gyp, adding
'libraries': ['/package/host/localhost/gcc-5/lib64/libstdc++.so.6'],
to each of the four specified targets, and then running node-gyp rebuild.
I also tried changing this to
'libraries': ['-L/package/host/localhost/gcc-5/lib64', '-lstdc++'],
, which appears to be syntactically valid, too—but still, it tries to load the library from the wrong path at runtime.
I stubled with a similar trouble and had resolve it with a trick uses dynamic load of libstdc++.so.6 through LD_PRELOAD:
LD_PRELOAD='/path/to/lib/libstdc++.so.6' /usr/bin/nodejs app.js

JXCore packaging, NPM errors

When I compile code with
\> jx package bin/www.js myApp
\> packaging...
\> [OK] compiled file is ready (myApp.jx)
it successfully created myApp.jx and myApp.jxp
But when I executed command
\> jx myApp.jx
It gives errors as:
C:\**\node_modules\express-session\node_modules\debug*node.js.jx*:72
exports.formatters.o = function(v) {
^
TypeError: Cannot set property 'o' of undefined
at Object. (C:\**\node_modules\express-session\node_modules\debug\node.js.jx:72:22)
at Module._compile (module.js:519:26)
at Object.Module._extensions..jx (module.js:1604:7)
at Module.load (module.js:346:36)
at Function.Module._load (module.js:313:12)
at Module.require (module.js:378:17)
at require (module.js:396:17)
at Object. (C:\**\node_modules\express-session*index.js.jx:17:13*)
at Module._compile (module.js:519:26)
at Object.Module._extensions..jx (module.js:1604:7)
at Module.load (module.js:346:36)
at Function.Module._load (module.js:313:12)
at Module.require (module.js:378:17)
at require (module.js:396:17)
at Object. (C:\***server.js.jx*:7:15)
at Module._compile (module.js:519:26)
I dont think,the problem is with NPM, step by step compile each of the .js file, and introduce required NPM package one by one , you will get the solution.
Since it is not a JXcore issue (the app fails with node too), you might want to seek the problem related with js-bson: Failed to load c++ bson extension, using pure JS version.
For example I saw this answer: Failed to load c++ bson extension, and they say it could be fixed by reinstalling modules with npm install.

GLIBC library version missmatch error while starting nodejs application on Openshift

I am newbie to MEAN stack and Linux hence please forgive me if my question is too obvious and stupid.
I have hosted a Nodejs application on Openshift. While trying to start the application I am facing following error due to GLIBC library version missmatch:
[Error: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /var/lib/openshift/550be20dfcf93378d600015e/app-root/runtime/repo/node_modules/mongodb/node_modules/mongodb-core/node_modules/bson/build/Release/bson.node)]
js-bson: Failed to load c++ bson extension, using pure JS version
/var/lib/openshift/550be20dfcf93378d600015e/app-root/runtime/repo/node_modules/mongoose/lib/drivers/node-mongodb-native/objectid.js:8
var ObjectId = require('mongodb').BSONPure.ObjectID;
^
TypeError: Cannot read property 'ObjectID' of undefined
at Object.<anonymous> (/var/lib/openshift/550be20dfcf93378d600015e/app-root/runtime/repo/node_modules/mongoose/lib/drivers/node-mongodb-native/objectid.js:8:43)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/var/lib/openshift/550be20dfcf93378d600015e/app-root/runtime/repo/node_modules/mongoose/lib/types/objectid.js:18:16)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
Current version of GLIBC on Opneshift is 2.12.
One obvious solution which I know is to upgrade GLIBC on Openshift. However that is not feasible as I am not having sudo rights on openshift.
Is there any possible workaround to solve the same issue?

Use classes on io.js in a file not in REPL

io.js released 1.0.1 version yesterday and, as the developers say, it's now possible to use classes without a nightly build.
But I'm not able to use ES6 classes without being in the REPL, e.g.:
$ iojs --use_strict --harmony_classes
> class Person {}
> [Function: Person]
But it I write it in a file, it doesn't work:
$ iojs test.js --use_strict --harmony_classes
class Person {}
^^^^^
SyntaxError: Unexpected reserved word
at exports.runInThisContext (vm.js:54:16)
at Module._compile (module.js:429:25)
at Object.Module._extensions..js (module.js:464:10)
at Module.load (module.js:341:32)
at Function.Module._load (module.js:296:12)
at Function.Module.runMain (module.js:487:10)
at startup (node.js:111:16)
at node.js:809:3
What am I doing wrong?
The command line arguments are not actually applied to iojs. Change the command to
iojs --use_strict --harmony_classes test.js
it will work fine now.

Resources