nodenv-nvmrc icon indicating copy to clipboard operation
nodenv-nvmrc copied to clipboard

Significant slowdown when this plugin is active; node starts 2-seconds slower

Open mattbrictson opened this issue 3 years ago • 1 comments

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

mattbrictson avatar May 14 '21 00:05 mattbrictson

From my investigation, the culprit is node package sh-semver which takes ~800ms on my machine

aymericbouzy avatar May 01 '22 14:05 aymericbouzy