Skip to main content

All Questions

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....
Mhd's user avatar
  • 1,088
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 ...
slider's user avatar
  • 2,816
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 ...
vyenkv's user avatar
  • 736
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": "...
Ed Graham's user avatar
  • 4,725
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 ...
zr0gravity7's user avatar
  • 3,224
9 votes
2 answers
18k views

Passing NODE_ENV into the npm script for Windows 10

I am using webpack in a Typescript project. I am following a tutorial where I have created 3 webpack files: webpack.common.js webpack.production.js webpack.development.js Within the tutorial's package....
Shan-Desai's user avatar
  • 3,359
3 votes
2 answers
9k views

Pass more than one variable to a package.json script

I have in package.json (NOT BASH, NOT SH, NOT ZSHELL, NOT FISH). So after we established the fact that this is my package.json file, let me present it to you: package.json "scripts": { "dev": ...
Stephan Kristyn's user avatar
1 vote
1 answer
2k views

The proper way to add multi-environment variables to my npm start script?

what is the proper way to add multi-environment variables to my npm start script? Right now I am using this (3 environment variables here) and it looks ugly: "scripts": { "start": "NODE_ENV='...
Qiulang's user avatar
  • 12.6k
6 votes
1 answer
3k views

How to run bash script from npm script that exports environment variables

I have a package.json that has the following script: "scripts": { "config": ". ./setup.sh" }, The setup.sh file prompts the user for an API token, read -p "Enter API Authorization Token: " val ...
wrobbinz's user avatar
  • 107