ehsueh
ehsueh3w ago

ehsueh - Hi, how can I import or install npm pa...

Hi, how can I import or install npm packages in a node? I want to use crypto
import crypto from 'node:crypto';

const hmac = crypto
.createHmac('sha256', 'your-secret-key')
.update('some-string')
.digest('base64');
import crypto from 'node:crypto';

const hmac = crypto
.createHmac('sha256', 'your-secret-key')
.update('some-string')
.digest('base64');
4 Replies
Gaurav Chadha
Gaurav Chadha3w ago
@ehsueh crypto is an inbuilt nodejs function, you don't need to import it. Also, you can use the AI builder (compass).
No description
ehsueh
ehsuehOP3w ago
Oh ok!! Thank you!! What if it was a package not included?
Gaurav Chadha
Gaurav Chadha2w ago
Use named imports for other packages, import fs from "fs"; - example if you'll build with the inbuilt AI builder (compass), you can eliminate all these issues.
ehsueh
ehsuehOP2w ago
Yes, I've been using that! Thanks!

Did you find this page helpful?