mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-10-26 04:10:36 +08:00
[New] allow .nvmrc files to support comments
In theory, `npx nvmrc` can now be used to validate an `.nvmrc` file that `nvm` will support. Allowances have been made for future extensibility, and aliases may no longer contain a `#`. Fixes #3336. Closes #2288. Co-authored-by: Jordan Harband <ljharb@gmail.com> Co-authored-by: Yash Singh <saiansh2525@gmail.com>
This commit is contained in:
13
README.md
13
README.md
@@ -298,6 +298,13 @@ To install a specific version of node:
|
||||
nvm install 14.7.0 # or 16.3.0, 12.22.1, etc
|
||||
```
|
||||
|
||||
To set an alias:
|
||||
|
||||
```sh
|
||||
nvm alias my_alias v14.4.0
|
||||
```
|
||||
Make sure that your alias does not contain any spaces or slashes.
|
||||
|
||||
The first version installed becomes the default. New shells will start with the default version of node (e.g., `nvm alias default`).
|
||||
|
||||
You can list available versions using `ls-remote`:
|
||||
@@ -563,7 +570,11 @@ Now using node v5.9.1 (npm v3.7.3)
|
||||
|
||||
`nvm use` et. al. will traverse directory structure upwards from the current directory looking for the `.nvmrc` file. In other words, running `nvm use` et. al. in any subdirectory of a directory with an `.nvmrc` will result in that `.nvmrc` being utilized.
|
||||
|
||||
The contents of a `.nvmrc` file **must** be the `<version>` (as described by `nvm --help`) followed by a newline. No trailing spaces are allowed, and the trailing newline is required.
|
||||
The contents of a `.nvmrc` file **must** contain precisely one `<version>` (as described by `nvm --help`) followed by a newline. `.nvmrc` files may also have comments. The comment delimiter is `#`, and it and any text after it, as well as blank lines, and leading and trailing white space, will be ignored when parsing.
|
||||
|
||||
Key/value pairs using `=` are also allowed and ignored, but are reserved for future use, and may cause validation errors in the future.
|
||||
|
||||
Run [`npx nvmrc`](https://npmjs.com/nvmrc) to validate an `.nvmrc` file. If that tool’s results do not agree with nvm, one or the other has a bug - please file an issue.
|
||||
|
||||
### Deeper Shell Integration
|
||||
|
||||
|
||||
Reference in New Issue
Block a user