0

I have created an application using node.js & protractor. the following start script is used in the package.json file for running my application

"start": "protractor conf/conf.js"

I have created a .env file and add one sample variable TestManaf='1234556' But it shows error like 'the value is undefined'.

After this, I have directly added TestManaf='1234556' in the start script.

"start": "set TestManaf='1234556' && protractor conf/conf.js"

It is working fine. Why .env file not supported? is any additional configuration required?

1
  • are you writing at any time to the proccess.env? this package takes care of it: npmjs.com/package/dotenv Commented May 8, 2020 at 10:32

1 Answer 1

2

You need to install the package dotenv

use the following command:

npm install dotenv

First thing you should do in your file is load the dotenv env vars, put this line as soon as possible in your import hierarchy.

require('dotenv').config()

You can see more information about using this package in the documentation

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.