Can I use .dotenv library as HTML script imports only without npm or node.js?

Is there a way to use dotenv library as an import (e.g from CDN) only in a HTML script tag or .js file?
I mean without node or npm require or imports.. Otherwise I would have to use something like webpack and I just want to test it quickly on a HTML page…

Answer

Short answer: No.

dotenv is a backend tool for getting variables set in a .env file. If you are using .env files for public use, that is misusing what the point of environment variables are for. Maybe try just using a filename.json or fileame.yml file for public consumption, but .env files are only used for secret things, like API keys, database passwords, etc.

Leave a Reply

Your email address will not be published. Required fields are marked *