In my node.js application I did an npm install btoa-atob
so that I could use the btoa()
and atob()
functions which are native in client-side javascript but for some reason weren't included in node. The new directory showed up in my node_modules
folder, which itself is in root alongside app.js
. Then I made sure to add btoa-atob as a dependency in my package.json
file which is in root.
However, for some reason, it still will not work.
console.log(btoa("Hello World!"));
^ should output "SGVsbG8gV29ybGQh" to the console, but instead, I get the error:
btoa is not defined.
Did I not do the install properly? What did I overlook?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…