question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Update to 10.0.0 breaks existing env-cmd npm scripts

See original GitHub issue

Hi,

I am using env-cmd in versin 9.0.3 and greenkeeper just got me the update in. I tried it out and the command just fail with sh: line 1: 4041 Terminated: 15. I checked the changelogs but cannot find any breaking change affecting me, since I use vanilla NodeJS 12.8.1.

An example command as I have it in my package.json: env-cmd cross-env DEBUG=false KNEX_SEED_DIR=./seeds/resetdb knex seed:run

I need to use the default .env file within my system and then override some env vars with cross-env. I would guess something about parsing this line has changed.

Maybe you can help me either “rewrite” the script so that I actually do not need both env-cmd and cross-env, or we find the bug breaking my script in the latest update.

Thanks!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
toddbluhmcommented, Aug 30, 2019

Ah gotcha, that would be a pain then. The other solution is an .env-cmdrc file with multiple environments. If you cannot use a .rc file then you are out of luck at this time.

With a .rc file you could create one environment called shared with common environment vars, then three other environments for each of those other scripts. Then something like env-cmd -e shared,environment1 .... That way you get the benefit of shared env vars and overriding/merging of the environments together.

Glad to hear it is working. Sorry about the breakage! I had forgotten to run it through my env-cmd-examples repo before releasing 🤦‍♂

1reaction
PeterMerkertcommented, Aug 30, 2019

The new version works! Thanks 💯

Regarding my problem: I see what you mean, but I have several scripts and each of them would require a special env file then:

"db-seed": "env-cmd cross-env DEBUG=false KNEX_SEED_DIR=./seeds/base knex seed:run",
    "db-testseeds": "env-cmd cross-env DEBUG=false KNEX_SEED_DIR=./seeds/test knex seed:run",
    "db-reset": "env-cmd cross-env DEBUG=false KNEX_SEED_DIR=./seeds/resetdb knex seed:run",

And in production my env vars cme from the k8s cluster. So I do not even have env-cmd there any more.

Thanks a lot for this package, we really love it https://retraced.co/ And thanks for the quick update 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

env-cmd | Yarn - Package Manager
A simple node program for executing commands using an environment from an env file. Install. npm install env-cmd or npm install -g env-cmd...
Read more >
scripts - npm Docs
How npm handles the "scripts" field. ... It is run AFTER the changes have been applied and the package.json and package-lock.json files have...
Read more >
env-cmd - npm
Executes a command using the environment variables in an env file. Latest version: 10.1.0, last published: 3 years ago. Start using env-cmd ......
Read more >
isml-linter - npm
ISML Linter is a tool for examining if your project's templates follow a specified set of rules defined by your dev team. The...
Read more >
@wordpress/scripts - npm
To update an existing project to a new version of ... keeping the breaking changes minimal so you can upgrade @wordpress/scripts as seamless ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found