motdotla / dotenv

Loads environment variables from .env for nodejs projects.
https://www.dotenvx.com
BSD 2-Clause "Simplified" License
19.14k stars 855 forks source link

Request for help! #791

Closed MCheping8108 closed 9 months ago

MCheping8108 commented 9 months ago

I want to use dotenv to load the .env file, but there is no error message in vscode, but this error message appears in the Microsoft Edge browser.

vscode

image

Microsoft Edge

image

zshnb commented 9 months ago

in browser you can't access process directly, you need use webpack do some polyfill then you can access process.env variables

StephenBuley commented 9 months ago

You also seem to be importing incorrectly. Here is the correct syntax for ES6 import: import ‘dotenv/config’

MCheping8108 commented 9 months ago

I have already switched to another method to replace the .env file.