TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Show HN: Run NPM Scripts with .envs

4 点作者 kraenhansen超过 3 年前

3 条评论

kraenhansen超过 3 年前
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.
kespindler超过 3 年前
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_k超过 3 年前
I still do not understand the pros of having these scripts in package.json instead of .&#x2F;scripts&#x2F;*.sh..
评论 #30083682 未加载
评论 #30081220 未加载