bcrypt is breaking my meteor application, how do I fix it? - node.js

I wasn't sure if this should be a stackoverflow or serverfault question.
I installed Meteor's accounts-password module and it worked locally, but broke my app when deployed to the server. Here's the scoop:
I'm running the latest Meteor 1.0.5 locally on OSX (OS just fully updated)
Building with --architecture os.linux.x86_64
Deploying to Ubuntu 14.04.2 LTS x86_64 (just updated)
Running nodejs v0.12.1 (freshly built)
Serving app with nginx v1.4.0
And still getting:
/home/secrethistory/bundle/programs/server/node_modules/fibers/future.js:245
throw(ex);
^
Error: Module did not self-register.
at Error (native)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at bindings (/home/secrethistory/bundle/programs/server/npm/npm-bcrypt/node_modules/bcrypt/node_modules/bindings/bindings.js:74:15)
at Object.<anonymous> (/home/secrethistory/bundle/programs/server/npm/npm-bcrypt/node_modules/bcrypt/bcrypt.js:3:35)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
Any tips or places to look next?

The bcrypt module is platform dependant (as fibers), so you need to remove the package after decompressing the bundle in your server:
rm -R path/to/bcrypt
then install it again:
npm install bcrypt

As of Meteor 1.0.5 (and this also applies to the forthcoming 1.1), we have not yet gone through the full testing, validation, and QA process with Node 0.12. I would recommend sticking with Node 0.10 until that point. While it is likely that it will mostly work, it's possible that some core changes will be necessary, and as you've seen, binary packages built against the 0.10 ABI don't work with 0.12.

Rebuilding bycrypt from souce fixed the problem of mine
npm rebuild bcrypt --build-from-source

Related

Please try re-compiling or re-installing Nodejs

Have upgraded our server from Ubuntu-18.04LTS to Ubuntu-20.04LTS After OS upgrade when I'm trying to start a nodejs application, but I get the below errors.
2021-11-14 10:48:01.641 - error: server-node-1: '[task-manager]
Error: The module \'/home/blruser/mibs/node_modules/weak/build/Release/weakref.node\'\nwas
compiled against a different Node.js version using\nNODE_MODULE_VERSION 57.
This version of Node.js requires\nNODE_MODULE_VERSION 64.
Please try re-compiling or re-installing\nthe module (for instance, using `npm rebuild` or `npm install`).\n at Object.Module._extensions..node (internal/modules/cjs/loader.js:807:18)\n at Module.load (internal/modules/cjs/loader.js:653:32)\n
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)\n
at Function.Module._load (internal/modules/cjs/loader.js:585:3)\n
at Module.require (internal/modules/cjs/loader.js:692:17)\n
at require (internal/modules/cjs/helpers.js:25:18)\n
at bindings (/home/blruser/mibs/node_modules/bindings/bindings.js:81:44)\n
at Object.<anonymous> (/home/blruser/mibs/node_modules/weak/lib/weak.js:7:35)\n
at Module._compile (internal/modules/cjs/loader.js:778:30)\n
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)\nWARN: uncaughtException be generated\n'
$ nodejs --version
v10.19.0
How do i re-compile without losing any existing application data? Please support. Thanks.
I'm not able to ask more info in comments. But have you tried deleting your node_modules directory and installing afresh using npm install or yarn install? This would not have any impact on your application data, rather just the node modules.
But if it's an electron project or similar, try running npm i -D electron-rebuild, following that do the above mentioned step.

Bcrypt file too short

I am facing an error that causes a crush on my nodejs application. The error is below:
'
Error: /home/*******/nodevenv/******/12/lib/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node: file too short
at Object.Module._extensions..node (internal/modules/cjs/loader.js:1057:18)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Module.require (internal/modules/cjs/loader.js:887:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (/home/outdoor1/nodevenv/prescription_server/12/lib/node_modules/bcrypt/bcrypt.js:6:16)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
internal/modules/cjs/loader.js:1057
return process.dlopen(module, path.toNamespacedPath(filename));
The application is hosted on CPanel-based shared hosting. The application is running for 6 months without error. But for 2 days the application is not running. I re-installed bcrypt. But nothing changes. The application working fine on my local pc.
It looks as if your bcrypt binary has somehow become corrupted.
What was the result of your attempt to reinstall bcrypt? Where there any errors?
The bcrypt repo at https://github.com/kelektiv/node.bcrypt.js notes that it only works on "stable" releases of NodeJS greater than >= 10.0.0 and more importantly, requires recompilation on the host platform on install. If your host does not have a full build environment installed, you will not be able to compile this module locally.
Assuming you are running the correct version of NodeJS, you could try retrieving the repo directly to your host machine, cd to its directory, and run npm install to install its requirements. Chief among these is the node-pre-gyp which is a helper to ease the compilation of native node modules.
Once you've done this, you should be able to run the install command for bcrypt itself, as described in the repo's package.json file: node-pre-gyp install --fallback-to-build. (Note that, depending on how your host is configured, you might need to add npx to the beginning of that command to properly invoke node-pre-gyp, e.g. npx node-pre-gyp install --fallback-to-build)
Note any errors this throws and share them here as an update to your question. I'm guessing that the install fails during compilation and you missed the error messages involved.
Baring everything else, I'd also ask CPanel support since I am sure this is not a unique problem.

Oops! I think I broke my work environment (nvm, npm, and node w/ angular). :(

It has been a long time since I programmed using my personal computer. I usually use a work computer. However, yesterday I decided to start working on a new pet project. Well, I went to set up the website in my Vagrant using VirtualBox, and now nvm, npm, and node are all messed up.
Every time I try to run npm install to set-up the node_module in my project, I get this error:
/home/vagrant/.nvm/v0.10.32/lib/node_modules/npm/lib/utils/unsupported.js:27
console.error(`a bug known to break npm. Please update to at least ${r
^
SyntaxError: Unexpected token ILLEGAL
at Module._compile (module.js:439:25)
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 /home/vagrant/.nvm/v0.10.32/lib/node_modules/npm/bin/npm-cli.js:19:21
at Object.<anonymous> (/home/vagrant/.nvm/v0.10.32/lib/node_modules/npm/bin/npm-cli.js:92:3)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
No matter what I try to do in npm (upgrade it, install, delete, uninstall, etc) it just throws this error.
Could somebody please help me?
The version of npm you have is not supported on Node v0.10.32. In fact Node v0.10 itself is not supported either and projects are actively dropping support it. Most dependencies will want node v4+ these days.
The version of npm you have installed will be available in the VM:
cat /home/vagrant/.nvm/v0.10.32/lib/node_modules/npm/package.json
You will need to manually extract one of the v2 or possibly even a v1 npm release over the files in /home/vagrant/.nvm/v0.10.32/lib/node_modules/npm.
Removing and setting up your nvm v0.10.32 environment again should also take npm back to a working release.
I would guess your Vagrant build does something like an npm install -g npm which would have worked at some stage but now installs the latest, incompatible version.
Use npm install -g npm#2 to stick to a v2.x release

NodeJS Module "userid" Error: Module version mismatch. Expected 46, got 47

I get the following error when trying to start my server.js which requires the module "userid".
module.js:460
return process.dlopen(module, path._makeLong(filename));
^
Error: Module version mismatch. Expected 46, got 47.
at Error (native)
at Object.Module._extensions..node (module.js:460:18)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:313:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object.<anonymous> (/root/backend/node_modules/userid/lib/userid.js:2:15)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
How can I solve this issue?
Not sure of the exact meaning of this error but my fix for this is to delete the node_modules directory and reinstall the required modules with npm install.
The above is a solution for this error showing up in a node project which uses locally installed modules. If there are some global modules that are throwing this error then you might have to reinstall those.
I would try upgrading the module version that causes the issue on package.json.
Another reason of this problem is that you have several different node versions installed at your system and you manage them with nvm. If you run node index.js and if you run sudo node index.js it may results in running different node version.
So if you installed your application modules with npm install and then run application with sudo node index.js you will have Module version mismatch error. In such case make sure with nvm that sudo node... run the same version of node as your application expects.
Also, while fixing initial problem you may have problem with nvm described here Can't use NVM from root (or sudo). One of possible solutions to this issue described in Yoo Matsuo's comment.

Node couchbase module on Ubuntu server 12.04 throws "Invalid ELF header" error

I'm trying to install a node app with couchbase on an Ubuntu server.
I have downloaded Couchbase and installed it from here (as listed on download page): http://packages.couchbase.com/releases/2.2.0/couchbase-server-enterprise_2.2.0_x86_64.deb
I can access it via web interface, it works fine.
Next, I try to install couchbase node module via npm:
npm install couchbase --save
This completes successfully. However when I try to run my app (which works fine on my desktop Ubuntu) I get this error:
ubuntu#aws-box:~/project/$ node index.js
/home/ubuntu/project/node_modules/couchbase/lib/binding.js:16
throw e;
^
Error:
/home/ubuntu/project/node_modules/couchbase/prebuilt/win/x64/couchbase_impl.node: invalid ELF header
at Module.load (module.js:349:32)
at Function.Module._load (module.js:305:12)
at Module.require (module.js:357:17)
at require (module.js:373:17)
at bindings (/home/ubuntu/project/node_modules/couchbase/node_modules/bindings/bindings.js:74:15)
at tryLoadBinding (/home/ubuntu/project/node_modules/couchbase/lib/binding.js:13:31)
at Object.<anonymous> (/home/ubuntu/project/node_modules/couchbase/lib/binding.js:30:17)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:349:32)
What's going wrong?
Those "prebuilt" folders are put there by the package author. This is a package bug, not an npm bug. Type npm bugs couchbase to go tell them.

Resources