Node js Error: Unable to load shared library - node.js

I'm trying to require any NodeJs addon that used "node-waf configure build" when installed with no luck. I keep getting the same message:
Error: Unable to load shared library /Users/xxxx/node_modules/pdfkit/node_modules/flate/lib/zlib_bindings.node
Error: Unable to load shared library /Users/xxxx/node_modules/rsa/rsaBinding.node
Error: Unable to load shared library /Users/xxxx/node_modules/dcrypt/build/default/dcrypt.node
addons I tried:
pdfkit, rsa, dcrypt
I'm on MacOsx 10.6.8, nodejs v0.6.5, npm .1.0-alpha-6

I encountered same problem with bcrypt and found it's because my node was 32bit and bcrypt was build as 64bit. After I build a 64bit node, all things work fine now.

PDFKit now uses the builtin zlib module from Node instead of the old flate dependency.

Related

How do I use zlib in a react app? or what is zlib_binding and why is it missing?

I have created a brand new react app using VS2022 and create-react-app.
I have installed zlib using npm install zlib.
getting the following error when running npm run start:
ERROR in ./node_modules/zlib/lib/zlib.js 1:0-43
Module not found: Error: Can't resolve './zlib_bindings' in 'c:\projects\mall\mall\node_modules\zlib\lib'
To troubleshoot, I created a test.js file with just require('zlib') in it and it works.
file ./node_modules/zlib/lib/zlib.js has import './zlib_bindings' as a single line in it. But there is no ./zlib_bindings.js.
Questions:
How do I fix this?
How does that work when I run node test.js?
Your test.js file works because you run it with node.
The zlib module provides compression functionality implemented using
Gzip and Deflate/Inflate. It is the part of nodejs core module written
in c++
This module can't be used outside of node.js
You can however try to use react-zlib-js and it should work!

The package at "node_modules\uuidv4\build\lib\uuidv4.js" attempted to import the Node standard library module "util"

I am getting below error when I am trying to run the react-native app on an android phone
Failed building JavaScript bundle.
The package at "node_modules\uuidv4\build\lib\uuidv4.js" attempted
to import the Node standard library module "util".
It failed because the native React runtime does not include the
Node standard library. Read more at
https://docs.expo.io/workflow/using-libraries/#using-third-party-libraries
But it is working on the web(web browser)....help me to fix this error
Try on your terminal and restart your VS Code or text editor
npm install util

NodeJS script on Docker: /lib64/libz.so.1: version `ZLIB_1.2.9' not found

I use sharp library for my image processing in the node js script which in turn is running my test cases using jest-image-snapshot.
I have got this error
/lib64/libz.so.1: version `ZLIB_1.2.9' not found
Found similar issue on NodeJS app on OpenShift: /lib64/libz.so.1: version `ZLIB_1.2.9' not found
and tried preloading the dependency.
But then, I have got error on preloading as well
ERROR: ld.so: object '/opt/app-root/src/node_modules/sharp/vendor/lib/libz.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
Please help to resolve this..
I have been trying this in my Windows OS
NOTE: The same script works fine in a mac OS

Error accessing mongodb from node: Failed to load c++ bson extension, using pure JS version

Just installed Mongo, mongodb driver and node. All current stable versions on a Ubuntu 14.04
mongo --version
MongoDB shell version: 3.2.1
node --version
v5.2.0
I'm pretty new to koa/mongo/node so I clone some github repos, but when I run code I always get this error:
{ [Error: Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' }
js-bson: Failed to load c++ bson extension, using pure JS version
Similar erros on stackoverflow are for older versions and there was either not clear solution or not working in my case.
How is the workflow? What is this extension for?
I tried reinstalling build-essential and node-gyp but without knowing the reason. Maybe is related to the monk or mongoose version if the projects are "old"?
You may be missing some build tools on your system.
In that case mongo driver will fallback to using a Javascript version of the bson parser, which is fine for development, but probably not in production.
Here is the solution:
cp ProjectDirectory/node_modules/monk/node_modules/mongodb/node_modules/bson/browser_build/bson.js ProjectDirectory/node_modules/monk/node_modules/mongodb/node_modules/bson/build/Release
I think you can use also move, I never tried.
The error message tell you bson.js is missing in "../build/Release folder", so you only have to put the file in the right place

error when i run nodejs on EC2

After I git clone my app onto EC2 and run it with the following command:
nohup nodejs app.js &
I get the following error:
[Error: /home/ubuntu/bluesky-scheduler2/node_modules/agenda/node_modules/mongodb/node_modules/bson/build/Release/bson.node: invalid ELF header]
js-bson: Failed to load c++ bson extension, using pure JS version
[Error: /home/ubuntu/bluesky-scheduler2/node_modules/mongodb/node_modules/bson/build/Release/bson.node: invalid ELF header]
js-bson: Failed to load c++ bson extension, using pure JS version
Any ideas how can I fix this?
I had the same issue. The invalid ELF header implies a binary that is not loadable or executable by the system. So I tried to build bson.
go to the root directory of the bson module.
e.g. in my case: mongodb/node_modules/bson
and then execute make
tldr;
$ cd /home/ubuntu/bluesky-scheduler2/node_modules/agenda/node_modules/mongodb/node_modules/bson/
$ make
This happened to me when I inadvertently committed the node_modules/mongodb folder in git after developing on a windows box. Most node modules will be generic javascript an run on either windows or linux, however mongodb has binary files specific to the operating system in the node_modules/mongodb folder. Deploying the code to linux pushes a windows binary to linux, hence the error.
The solution is to remove the nodemodules/mongodb directory on the linux server, then run npm install to install mongodb dependancies from the linux environment.

Resources