1

I've got a config section in my package.json which holds 2 environment variables ( port & host ). Inside my .js I'd be able to use process.env.npm_package_config_port or config_host to access the values.

Below is the config section in my node app package.json. As you can see I've added two variables into it (host and port). I'm needing to reference those values in my scripts object (Below).

"config": {
    "port":"3000",
    "host": "localhost"
  },
"scripts": {
    "start": "env NODE_ENV=DEV rnws start --hostname config.host",
    .....
}

As you can see I'm trying to refernce the config.host value inside the start script. But this doesn't work. I've also try NODE_ENV.config_host to reference the value but it doesn't work either. Any ideas?

1 Answer 1

1

Per package.json

For Windows, please try

"start": "env NODE_ENV=DEV rnws start --hostname %npm_package_config_host%",

For Linux, please try

"start": "env NODE_ENV=DEV rnws start --hostname $npm_package_config_host",
Sign up to request clarification or add additional context in comments.

1 Comment

Awesome! I actually didn't think it was possible before I saw this.

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.