TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: Run NPM Scripts with .envs

4 pointsby kraenhansenover 3 years ago

3 comments

kraenhansenover 3 years ago
I built this package while working on an app that I deployed to production, staging and my local dev environment. I had a couple of scripts (one to deploy, one to migrate the database, etc.) that I wanted to run, but I didn&#x27;t want to have to maintain one script for each environment doing almost the same but to different endpoints.<p>So, I built a simple CLI that reads one or more .env files and spawns a new child process running an NPM script from the package, with the environment variables extended with the contents of the files.<p>It also supports expansion, where one file use the value defined in another file.<p>Please see the README for more details and usage and consider giving it a spin in your next project if you&#x27;re faced with a similar problem.
kespindlerover 3 years ago
Instead, I highly recommend <a href="https:&#x2F;&#x2F;github.com&#x2F;casey&#x2F;just" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;casey&#x2F;just</a> .<p>Add these two lines to the top to use node executables and load the dotenv:<p>``` set dotenv-load := true export PATH := &quot;.&#x2F;node_modules&#x2F;.bin:&quot; + env_var(&#x27;PATH&#x27;) ```
评论 #30083652 未加载
marius_kover 3 years ago
I still do not understand the pros of having these scripts in package.json instead of .&#x2F;scripts&#x2F;*.sh..
评论 #30083682 未加载
评论 #30081220 未加载