1

I am running some UI tests using WebdriverIO using npm.

My .env file:

VARIABLE=SOME-VALUE

package.json:

"scripts": {
    "test": "dotenv -e .env tsc && wdio wdio.conf.ts"
  },

How I am accessing the variable:

const myVariable = process.env.VARIABLE

All three files are in same directory. When I console log the myVariable, i get undefined. I am not getting what is missing. I referred few answers here, but they are not helping.

Also, if someone could throw light on do we need to/how to import the file. I am fairly new to this, hence any help would be appreciated.

Tech Girl
  • 11
  • 3
  • 1
    Does this answer your question? [dotenv file is not loading environment variables](https://stackoverflow.com/questions/42335016/dotenv-file-is-not-loading-environment-variables) – cinnaroll45 Feb 25 '22 at 06:33
  • @cinnaroll45 I checked this link. This isn't helping me. – Tech Girl Feb 28 '22 at 07:45

0 Answers0