A lightweight GitHub Action that sets sensible npm defaults to speed up installs and cut unnecessary energy use in CI.
- 🔒 dependency-free
- ⚛️ small size
- 💰 saves time & money
- 🌎 reduces carbon emissions
pairs seamlessly with actions/setup-nodeand all active Node LTS versions
After setting up Node with actions/setup-node, add this step:
jobs:
test:
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
- uses: lowlydba/sustainable-npm@v2To override any defaults:
- uses: lowlydba/sustainable-npm@v2
with:
audit: 'true'
fund: 'false'
progress: 'false'
save: 'false'
update-notifier: 'false'
loglevel: 'warn'The npm configuration is only printed when debug logging is enabled (RUNNER_DEBUG == 'true').
| Input | Description | Allowed Values | Default |
|---|---|---|---|
audit |
Run a security audit after install. | 'true' or 'false' |
'false' |
fund |
Show funding messages. | 'true' or 'false' |
'false' |
progress |
Show a progress bar during npm operations. | 'true' or 'false' |
'false' |
save |
Automatically update package.json when installing packages. |
'true' or 'false' |
'false' |
update-notifier |
Check for npm updates after each command. | 'true' or 'false' |
'false' |
prefer-offline |
Use cached data without checking for staleness. Uncached packages are still fetched. | 'true' or 'false' |
'true' |
loglevel |
npm log level. | silent, error, warn, http, info, verbose, silly |
'error' |
The "Print npm configs" step now only runs when debug logging is enabled (RUNNER_DEBUG == 'true'). To re-enable it, set that variable in your workflow.
Benchmarks via hyperfine, 20 runs with 3 warmups:
$ hyperfine 'npm install' 'npm install --audit=false --fund=false --loglevel=error --update-notifier=false --progress=false' --ignore-failure --runs 20 --warmup 3
Benchmark 1: npm install
Time (mean ± σ): 2.172 s ± 0.097 s [User: 1.958 s, System: 0.750 s]
Range (min … max): 2.017 s … 2.347 s 20 runs
Benchmark 2: npm install --audit=false --fund=false --loglevel=error --update-notifier=false --progress=false
Time (mean ± σ): 1.849 s ± 0.107 s [User: 1.819 s, System: 0.668 s]
Range (min … max): 1.626 s … 2.046 s 20 runs
Summary
npm install --audit=false --fund=false --loglevel=error --update-notifier=false --progress=false ran
1.17 ± 0.09 times faster than npm installAround a 10-20% reduction in install time on projects with ~500 dependencies. Packages were pre-downloaded to keep network conditions out of the equation.
Note
Your actual gains will vary based on project size, network, and OS.
Add a badge to your repo:
[](https://github.com/lowlysre/sustainable-npm)