nvmrc-gen
is a CLI utility that generates a .nvmrc
file in a Node project for use with nvm
. It searches the project's dependencies and finds the minimum (or maximum) Node version compatible with the project.
nvmrc-gen
's primary purpose is for use in CI/CD pipelines, but it can also be useful for developers generating .nvmrc
files for their own use.
Add nvmrc-gen
to your PATH
or copy it directly where it is intended to be ran, then run it there. It uses the working directory of the shell it is ran from.
![image](https://private-user-images.githubusercontent.com/39097222/326677914-d1cfc51d-4436-4878-b8e9-e776bd152e9b.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjU5NjU1MzAsIm5iZiI6MTcyNTk2NTIzMCwicGF0aCI6Ii8zOTA5NzIyMi8zMjY2Nzc5MTQtZDFjZmM1MWQtNDQzNi00ODc4LWI4ZTktZTc3NmJkMTUyZTliLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEwVDEwNDcxMFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWJkNDU1ZWY3ZTQyZDJhNDJlMjNkNjU4NGQzODA4NzcxOTJkNjc4MjBmN2ZmMmZjZmY5MDBiNWJlYmFjZTM5YzMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.pIuRywCzHkTjLW_VKTQ6uMLAh0iEi7xxFksP9nIB5YE)
Flag | Description |
---|---|
-c |
CI mode. Don't prompt for writing of files. |
-l |
Include non-LTS (oddly versioned) Node releases. |
-m |
Get max Node version rather than min Node version. |
-s |
Silent mode. Output no logs. |
Clone this repository and run go build -ldflags="-w -s" -gcflags=all=-l -o /path/to/output/nvmrc-gen
to build for your architecture.
To build for other architectures, run env GOOS=<OS> GOARCH=<arch> go build -ldflags="-w -s" -gcflags=all=-l -o /path/to/output/nvmrc-gen
.
The following builds are available in each release:
Target | amd64 |
arm |
arm64 |
---|---|---|---|
macOS (darwin) | ✅ | ❌ | ✅ |
FreeBSD | ✅ | ✅ | ✅ |
Linux | ✅ | ✅ | ✅ |
NetBSD | ✅ | ✅ | ✅ |
OpenBSD | ✅ | ✅ | ✅ |
Windows | ✅ | ✅ | ✅ |
The .zip file for each OS and arch is formatted as nvmrc-gen-<OS>-<arch>-<version>.zip
. For example, the amd64
for macOS build of nvmrc-gen
v0.1.0 is named nvmrc-gen-darwin-amd64-0.1.0.zip
.
Feel free to contribute in any way you like. This was my first project in Go, and it shows.
- Better error handling