https://github.com/nodenv/nodenv-nvmrc
nodenv plugin that detects the node version based on .nvmrc.
https://github.com/nodenv/nodenv-nvmrc
node nodejs nodenv nodenv-plugin nvm nvmrc version-manager
Last synced: 29 days ago
JSON representation
nodenv plugin that detects the node version based on .nvmrc.
- Host: GitHub
- URL: https://github.com/nodenv/nodenv-nvmrc
- Owner: nodenv
- Created: 2018-01-19T09:09:01.000Z (over 7 years ago)
- Default Branch: main
- Last Pushed: 2025-08-28T12:58:41.000Z (about 1 month ago)
- Last Synced: 2025-08-28T20:22:49.399Z (about 1 month ago)
- Topics: node, nodejs, nodenv, nodenv-plugin, nvm, nvmrc, version-manager
- Language: Shell
- Homepage:
- Size: 47.9 KB
- Stars: 40
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# nodenv-nvmrc
A [nodenv][] plugin to activate Node version from `.nvmrc`.
[](https://github.com/nodenv/nodenv-nvmrc/actions/workflows/test.yml)
[](https://github.com/nodenv/nodenv-nvmrc/releases/latest)
[![Latest Homebrew Release]()](https://github.com/nodenv/homebrew-nodenv/blob/main/Formula/nodenv-nvmrc.rb)
[](https://www.npmjs.com/package/@nodenv/nodenv-nvmrc/v/latest)This is a plugin for [nodenv](https://github.com/nodenv/nodenv)
that detects the node version based on the current tree's .nvmrc. `.node-version` files still take precedence.When .nvmrc is configured with a range this plugin chooses the greatest installed version matching the range or exits with an error if none match.
## Installation
### Installing with git
```sh
$ git clone https://github.com/nodenv/nodenv-nvmrc.git $(nodenv root)/plugins/nodenv-nvmrc
```### Installing with Homebrew
Mac OS X users can install [many nodenv plugins](https://github.com/nodenv/homebrew-nodenv) with [Homebrew](http://brew.sh).
*This is the recommended method of installation if you installed nodenv with
Homebrew.*```sh
$ brew tap nodenv/nodenv
$ brew install nodenv-nvmrc
```## Usage
Once you've installed the plugin you can verify that it's working by `cd`ing into a project that has a `.nvmrc` file and does not have a `.node-version` file. From anywhere in the project's tree, run `nodenv which node`.
## Gotcha
Due to the limitaion of nodenv's plugin system, some commands were not reading the version from `.nvmrc`.
- `nodenv install` without version is not able to install new Node version specified in `.nvmrc`.
- `nodenv local` without version is not able to retrieve the version specified in `.nvmrc`## Contributing
To run tests, install [bats](https://github.com/sstephenson/bats) and [nodenv](https://github.com/nodenv/nodenv), then run `bats test` in the base directory of this plugin
## Credits
This project is heavily inspired by nodenv-package-json-engine[[1]](https://github.com/nodenv/nodenv-package-json-engine).
Shell semver range support provided by [sh-semver](https://github.com/qzb/sh-semver).
[nodenv]: https://github.com/nodenv/nodenv