bellstrand/totp-generator

Error: Cannot find module 'totp-generator' -> Even I installed it

stephenwang1011 opened this issue · 3 comments

@stephenwang1011 For NodeJS to find a package it needs to be installed locally inside the folders node_modules.
You just installed the package globally with the -g flag, remove it and everything should work.

otplib is also unmaintained... its still using node exclusive APIs like Buffer and Crypto, breaking browser support, deno, synode, etc. They also export a UMD browser bundle thats incompatible with ES Module builders and browser's module loader.

This seems better... but will require Node 16. If you are on typescript you may need to recast webcrypto as as unknown as WebCrypto

Sandbox:
https://stackblitz.com/edit/vitejs-vite-tzrvwp

Based on PR Pending:
https://github.com/dpikalov/hotp-totp/blob/master/index.js