How to use environment variables in package.json
Let's use grep to get a value environment variable from the .env file.
"scripts": { "start": "NODE_ENV=$(grep NODE_ENV .env | cut -d '=' -f2) some_script"}
I have similar but different requirement. For me, I want to use environment variables in the scripts.
Instead of using the environment variables directly in package.json, I do:
"some-script": "./scripts/some-script.sh",
And in some-script.sh:
#!/bin/shnpm run some-other-script -- --prop=$SOME_ENV_VAR
No, it's not possible. You should access the repo using git+ssh
, and store a private key in ~/.ssh
.
Your line then looks like:
"my-private-module":"git+ssh://git@bitbucket.org/foo/bar.git"
Which doesn't contain anything sensitive.