简体   繁体   中英

how to manually use an "internal" meteor package?

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 ?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM