https://github.com/nodenv/nodenv-package-json-engine
Activate a nodenv node version from package.json#engines.node field
https://github.com/nodenv/nodenv-package-json-engine
nodenv-plugin
Last synced: about 1 year ago
JSON representation
Activate a nodenv node version from package.json#engines.node field
- Host: GitHub
- URL: https://github.com/nodenv/nodenv-package-json-engine
- Owner: nodenv
- Created: 2015-11-02T03:27:25.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2024-12-04T20:25:35.000Z (over 1 year ago)
- Last Synced: 2025-05-08T21:15:40.857Z (about 1 year ago)
- Topics: nodenv-plugin
- Language: Shell
- Homepage:
- Size: 212 KB
- Stars: 40
- Watchers: 5
- Forks: 3
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# nodenv-package-json-engine
[](https://github.com/nodenv/nodenv-package-json-engine/releases/latest)
[](https://www.npmjs.com/package/@nodenv/nodenv-package-json-engine/v/latest)
[](https://github.com/nodenv/nodenv-package-json-engine/actions?query=workflow%3ATest)
This is a plugin for [nodenv](https://github.com/nodenv/nodenv)
that detects the Node version based on the [`engines`](https://docs.npmjs.com/files/package.json#engines) field of the current tree's `package.json` file. The `$NODENV_VERSION` environment variable (set with `nodenv shell`) and `.node-version` files still take precedence.
When `engines` is configured with a range this plugin chooses the greatest installed version matching the range, or exits with an error if none match.
- [Installation](#installation)
* [Installing with Git](#installing-with-git)
* [Installing with Homebrew](#installing-with-homebrew)
- [Usage](#usage)
- [Contributing](#contributing)
- [Credits](#credits)
## Installation
### Installing with Git
```sh
$ git clone https://github.com/nodenv/nodenv-package-json-engine.git $(nodenv root)/plugins/nodenv-package-json-engine
```
### 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-package-json-engine
```
## Usage
Once you've installed the plugin you can verify that it's working by `cd`ing into a project that has a `package.json` file with `engines` and does not have a `.node-version` file. From anywhere in the project's tree, run `nodenv which node`.
## Contributing
`npm install` and `npm test` from within the project.
## Credits
`package.json` inspection and SemVer integration heavily inspired by nvmish [[1]](https://github.com/goodeggs/homebrew-delivery-eng/blob/master/nvmish.sh) [[2]](https://gist.github.com/assaf/ee377a186371e2e269a7) and [rbenv-bundler-ruby-version](https://github.com/aripollak/rbenv-bundler-ruby-version).
Shell semver range support provided by [sh-semver](https://github.com/qzb/sh-semver).
`package.json` parsing provided by [JSON.sh](https://github.com/dominictarr/JSON.sh).