how to manually use an "internal" meteor package?

120 views Asked by At

I'm using meteor and I have accounts-password package installed, so it came with bcrypt. Good thing because I want to use it to manually hash some other data.

I do have this package in my packages.json ("bcrypt": "^4.0.1") and I can see its folder in ./.meteor/packages/npm-bcrypt

However I can't figure out how to use it "manually". I tried importing, I tried simply using bcrypt.hash() but it throws an error saying it is undefined. Tried const bcrypt = require('bcrypt');

How do I do this ?

1

There are 1 answers

4
Tom Freudenberg On

You need to install this npm to your own project as well

meteor npm install --save bcrypt

and then use import that to your source like

import bcrypt from 'bcrypt';

// this is equivalent to the standard node require:
const bcrypt = require('bcrypt');

Read more at meteor guide

https://guide.meteor.com/using-npm-packages.html

Good luck