ouchxp / nodenv-nvmrc Goto Github PK
View Code? Open in Web Editor NEWnodenv plugin that detects the node version based on .nvmrc.
nodenv plugin that detects the node version based on .nvmrc.
When a directory contains .node-version
file you can run nodenv install
with node-build installed and node-build picks up the required version then installs it.
Any chance you could allow for that? I realize that requires checking whether another plugin is installed, but I commonly default to nodenv install
in bin/setup
-type scripts.
PS: Thanks for this plugin, I have a ton of old projects with .nvmrc
files all over the place and it's way easier to deal with them with this.
$ cat .nvmrc v6.12.0
$ cat ~/.nodenv/version 8
$ nodenv which node /Users/sweth/.nodenv/versions/6.12.0/bin/node
$ nodenv version 6.12.0 (set by /Users/sweth/.nodenv/version)
When using e.g. an LTS version by name in .nvmrc
(such as lts/dubnium
), one of the plugins dependencies, sh-semver
, chokes:
/usr/local/bin/../Cellar/nodenv-nvmrc/1.0.1/bin/../node_modules/sh-semver/semver.sh: line 138: [: lts: integer expression expected
/usr/local/bin/../Cellar/nodenv-nvmrc/1.0.1/bin/../node_modules/sh-semver/semver.sh: line 142: [: lts: integer expression expected
/usr/local/bin/../Cellar/nodenv-nvmrc/1.0.1/bin/../node_modules/sh-semver/semver.sh: line 138: [: lts: integer expression expected
/usr/local/bin/../Cellar/nodenv-nvmrc/1.0.1/bin/../node_modules/sh-semver/semver.sh: line 142: [: lts: integer expression expected
/usr/local/bin/../Cellar/nodenv-nvmrc/1.0.1/bin/../node_modules/sh-semver/semver.sh: line 138: [: lts: integer expression expected
/usr/local/bin/../Cellar/nodenv-nvmrc/1.0.1/bin/../node_modules/sh-semver/semver.sh: line 142: [: lts: integer expression expected
[...]
nvmrc: no version satisfying `lts/dubnium' installed
Without nodenv-nvmrc
, NODENV_VERSION
supercedes .node-version
. It seems like NODENV_VERSION
should also supercede .nvmrc
when using nodenv-nvmrc
.
Repro:
> echo "12.15.0" > .node-version
> nodenv version
nodenv: version `12.15.0' is not installed (set by /Users/matttingen/test/.node-version)
> NODENV_VERSION=12.14.0 nodenv version
nodenv: version `12.14.0' is not installed (set by NODENV_VERSION environment variable)
> rm .node-version
> echo "12.13.0" > .nvmrc
> nodenv version
nodenv: version `12.13.0' is not installed (set by /Users/matttingen/test/.nvmrc)
> NODENV_VERSION=12.14.0 nodenv version
nodenv: version `12.13.0' is not installed (set by /Users/matttingen/test/.nvmrc
nodenv traverses the file hierarchy upwards until it finds a
.node-version
file or falls back to~/.nodenv/version
, if that exists.
That means I can't override either a root directory's Node version or my global version via a local.nvmrc
file because of this skip.
Originally posted by @lumaxis in #5 (comment)
I think the problem here is should_find_in_nvmrc()
because for a use case like mine, nodenv local
will return the root folder's version from ../.node_version
.
With this plugin installed, directories that contain an .nvmrc
file cause node to become very slow to start. Directories with a .node-version
file are not affected.
$ echo "16.1.0" > .node-version
$ time node -v
v16.1.0
real 0m0.105s
user 0m0.038s
sys 0m0.042s
$ mv .node-version .nvmrc
$ time node -v
v16.1.0
real 0m2.109s
user 0m1.120s
sys 0m1.455s
So it seems that this plugin is making node 2 seconds slower to start.
I am using nodenv and nodev-nvmrc installed via homebrew on macOS 11.3.1 (x86_64).
$ nodenv --version
nodenv 1.4.0
$ brew info nodenv-nvmrc
nodenv/nodenv/nodenv-nvmrc: stable 1.0.5, HEAD
Pick a node version from .nvmrc
https://github.com/ouchxp/nodenv-nvmrc
/usr/local/Cellar/nodenv-nvmrc/1.0.5 (17 files, 29KB) *
Built from source on 2021-05-13 at 17:16:04
From: https://github.com/nodenv/homebrew-nodenv/blob/HEAD/Formula/nodenv-nvmrc.rb
==> Dependencies
Required: nodenv โ
==> Options
--HEAD
Install HEAD version
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.