简体   繁体   English

nvmrc更改时如何运行nvm?

[英]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. 我使用direnvnvmrc文件强制nvm install到你每次运行cd到该目录,确保如果你正在运行的项目使用的是正确的节点版本。

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. 但是,我注意到如果其他人更改了nvmrc文件的版本并且我git pull (或rebase)更改,它不会自动更新我的节点版本,因为它只在我进入目录时运行。

Has anyone done something to watch the nvmrc file or somehow make it change more often than just on cd ? 有没有人做过什么来观看nvmrc文件或以某种方式让它更频繁地改变而不仅仅是在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: 由于direnv的.envrc文件是在每个提示符下进行评估的,因此对于您的用例,我只需在项目的.envrc放置一个显式的nvm install <version number> ,例如:

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. 虽然,就个人而言,我更喜欢只使用nvm use <version number>并且让nvm本身指出如果请求的版本不可用,则尚未安装给定版本的节点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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