Chandru
Chandru

Reputation: 11

Cannot read property '_handle' of undefined -> Meteor + Nodejs + Trying to run bcrypt

I'm trying to add the bcryptjs package and use it in my Meteor app.

I have installed bcrypt via meteor npm install --save bcrypt and it went okay.

I use import bcrypt from 'bcrypt'; to start using bcrypt functions.

However, I run into this problem where the console log throws this error:

Uncaught TypeError: Cannot read property '_handle' of undefined
at modules.js?hash=0a5b088c5613f9a01f50dd13461d2cc4ca666b66:35733
at Array.forEach (<anonymous>)
at module.exports (modules.js?hash=0a5b088c5613f9a01f50dd13461d2cc4ca666b66:35732)
at log.js (modules.js?hash=0a5b088c5613f9a01f50dd13461d2cc4ca666b66:29972)
at fileEvaluate (modules-runtime.js?hash=8587d188e038b75ecd27ed2469a52b269e38fb62:343)
at require (modules-runtime.js?hash=8587d188e038b75ecd27ed2469a52b269e38fb62:238)
at node-pre-gyp.js (modules.js?hash=0a5b088c5613f9a01f50dd13461d2cc4ca666b66:27190)
at fileEvaluate (modules-runtime.js?hash=8587d188e038b75ecd27ed2469a52b269e38fb62:343)
at require (modules-runtime.js?hash=8587d188e038b75ecd27ed2469a52b269e38fb62:238)
at bcrypt.js (modules.js?hash=0a5b088c5613f9a01f50dd13461d2cc4ca666b66:26761)

After digging a bit, it appears that the set-blocking node package was throwing this error (there was no stream while the package uses stream._handle).

I couldn't find any specific answer w.r.t a Meteor context here on SO.

Can someone help?

Thanks in advance.

Upvotes: 1

Views: 1095

Answers (2)

Adam Wolski
Adam Wolski

Reputation: 5656

The issue occurs because you are loading bcrypt library on the client.

Import bcrypt library only in the files that are run in meteor server.

Upvotes: 0

DoctorPangloss
DoctorPangloss

Reputation: 3073

Use bcryptjs instead.

https://www.npmjs.com/package/bcryptjs

You probably have an unusual server configuration that has busted your ability to use bcrypt the way you expect.

Upvotes: 1

Related Questions