简体   繁体   中英

How to have nvm run when nvmrc changes?

I am using direnv and an nvmrc file to force nvm install to run every time you cd into the directory, making sure if you are running the project you are using the correct node version.

However, I noticed that if someone else changes the nvmrc file's version and I git pull (or rebase) the change, it doesn't automatically update my node version because it only runs when I enter the directory.

Has anyone done something to watch the nvmrc file or somehow make it change more often than just on cd ?

Since direnv's .envrc file is evaluated at each prompt, for your use case I would just place an explicit nvm install <version number> in your project's .envrc , eg:

nvm install 10.16.0

Although, personally, I prefer to just have an nvm use <version number> and let nvm itself point out that a given version of node isn't installed yet if the requested version isn't available.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM