mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-05-11 14:51:49 +00:00
Use .nvmrc file to to switch node version
This commit is contained in:
parent
6dbf497000
commit
ac7e0a8dee
@ -195,13 +195,13 @@ add-zsh-hook chpwd load-nvmrc
|
|||||||
##### Automatic version switching for `.bashrc` with fallback to `nvm use default`
|
##### Automatic version switching for `.bashrc` with fallback to `nvm use default`
|
||||||
|
|
||||||
Put this into your `$HOME/.bashrc` to enable automatic version swithing whenever you enter a directory than contains an
|
Put this into your `$HOME/.bashrc` to enable automatic version swithing whenever you enter a directory than contains an
|
||||||
`.node-version` file with a string telling nvm which node to `use`:
|
`.nvmrc` file with a string telling nvm which node to `use`:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd() {
|
cd() {
|
||||||
builtin cd "$@"
|
builtin cd "$@"
|
||||||
if [[ -f .node-version && -r .node-version ]]; then
|
if [[ -f .nvmrc && -r .nvmrc ]]; then
|
||||||
nvm use "`cat .node-version`"
|
nvm use
|
||||||
elif [[ `nvm current` != `nvm version default` ]]; then
|
elif [[ `nvm current` != `nvm version default` ]]; then
|
||||||
nvm use default
|
nvm use default
|
||||||
fi
|
fi
|
||||||
@ -216,8 +216,8 @@ For example, on Ubuntu it should be placed into `$HOME/.bash_profile`:
|
|||||||
```bash
|
```bash
|
||||||
cd() {
|
cd() {
|
||||||
__zsh_like_cd cd "$@"
|
__zsh_like_cd cd "$@"
|
||||||
if [[ -f .node-version && -r .node-version ]]; then
|
if [[ -f .nvmrc && -r .nvmrc ]]; then
|
||||||
nvm use "`cat .node-version`"
|
nvm use
|
||||||
elif [[ `nvm current` != `nvm version default` ]]; then
|
elif [[ `nvm current` != `nvm version default` ]]; then
|
||||||
nvm use default
|
nvm use default
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user