All Questions
Tagged with npm-scripts environment-variables
22 questions
2
votes
1
answer
941
views
How do you pass an environment variable from a script to a React Native file?
I feel like I'm doing everything right but I must be going wrong somewhere. I'm not using Expo or create-react-app. I'm on a Macbook.
First, I run npm run start, which runs a script. The script looks ...
0
votes
1
answer
332
views
How to rename .env variables in package.json?
What I have
I have multiple projects using Percy for Cypress where I set the PERCY_TOKEN env variable inside the .env file. The token is different for each project. In the CI I set different env ...
0
votes
2
answers
4k
views
Set environment variables in package.json
I've had a look at quite a number of answers to questions similar to mine but i've not been able to find a working solution for my use case yet.
I've got an environment variable of lets say auth=false....
1
vote
1
answer
951
views
Build react app multiple times with different environment variables
I have a development environment file .env.development and a production .env file for my React web app.
The .env.development has a value REACT_APP_NAME=My Test App and the .env file has the value ...
0
votes
1
answer
3k
views
Set variable in npm script to env var from file
I'd like to set a variable FOO (that is not in my .env file) in an npm script command to the value of the environment variable BAR (which is in the .env file).
For example, my .env file:
BAR=1234
And ...
1
vote
0
answers
606
views
How to pass dotenv variables to npm script?
I need to read a variable from .env file and pass it to an npm script (or make it available for the script).
I tried it like this with dotenv library:
dotenv -e .env -- graphql-faker api-extension.gql ...
2
votes
0
answers
3k
views
ENV vars are not set through npm start (run-script) (on Windows git-bash)
I have installed git-bash to be able to set env vars like that <VAR>=<value> node ..., but now it's working only if I run node. If I do it through npm start ("start": "ENV=...
2
votes
1
answer
3k
views
Cross-platform way to set environment variables *with spaces* in npm scripts
I am developing a serverless NodeJS app and need to test it in offline mode. I have an npm script in a package.json file that looks like this:
"scripts": {
"serve": "...
1
vote
1
answer
627
views
platform agnostic USER in npm script
I am looking for a way to pass the os username in an npm script. However, I need the script to be able to run platform agnostic. Is there anyway I can do this?
On unix I can do;
{
"scripts":...
0
votes
1
answer
390
views
Convert an argument passed to an npm script to an environment variable
This is my package.json:
"scripts": {
"start": "bash do_something.sh && jest",
"...": "..."
}
In my package, there is the package.json and do_something.sh files at the package root, and a ...
6
votes
5
answers
28k
views
How can I configure my prod env vars when I run my build process?
I'm building a React 16.13.0 application. I want to configure an endpoint differently, per environment, so I have set this up in a component, src/containers/FormContainer.jsx, ...
class ...
0
votes
1
answer
1k
views
Docker-compose pass environment variable to docker container and into npm start
Having spent far too long on this, and read copious reference material on docker and many many stack overflow articles I have to admit defeat and ask the panel for help
What I want to achieve is to ...
0
votes
1
answer
869
views
how to use package.json to call a script that sets environment variables and have those variables accessible to other scripts and commands
I have a cookiecutter Flask app. I am trying to modify my package.json so that the command npm start sets some environment variables with a Python script.
Right now my Python script appears to be ...
0
votes
0
answers
1k
views
Pass an environment variable to a npm script that invokes a node script?
I have the following node script to start a react app. It sets a variamle in the .env. Is there a way to set this script in the package.json, so it can take a parameter from the terminal?
script in ...
0
votes
0
answers
520
views
Environment variables are not being set in npm scripts using cross-env
I am trying to run npm run test, where part of test is setting an environment variable using cross-env. However, in Cypress testing the environment variable is not actually changed. Thanks for the ...