Skip to content

Commit a5512c6

Browse files
authored
docs: add custom Node.js mirror docs and rename VITE_NODE_DIST_MIRROR to VP_NODE_DIST_MIRROR (#1254)
1 parent 695dabe commit a5512c6

File tree

5 files changed

+22
-7
lines changed

5 files changed

+22
-7
lines changed

crates/vite_js_runtime/src/providers/node.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ fn calculate_expires_at(max_age: Option<u64>) -> u64 {
558558

559559
/// Get the Node.js distribution base URL
560560
///
561-
/// Returns the value of `VITE_NODE_DIST_MIRROR` environment variable if set,
561+
/// Returns the value of `VP_NODE_DIST_MIRROR` environment variable if set,
562562
/// otherwise returns the default `https://nodejs.org/dist`.
563563
fn get_dist_url() -> Str {
564564
vite_shared::EnvConfig::get().node_dist_mirror.map_or_else(

crates/vite_shared/src/env_config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ pub struct EnvConfig {
6565

6666
/// Node.js distribution mirror URL.
6767
///
68-
/// Env: `VITE_NODE_DIST_MIRROR`
68+
/// Env: `VP_NODE_DIST_MIRROR`
6969
pub node_dist_mirror: Option<String>,
7070

7171
/// Whether running in a CI environment.
@@ -136,7 +136,7 @@ impl EnvConfig {
136136
.unwrap_or_else(|_| "https://registry.npmjs.org".into())
137137
.trim_end_matches('/')
138138
.to_string(),
139-
node_dist_mirror: std::env::var(env_vars::VITE_NODE_DIST_MIRROR).ok(),
139+
node_dist_mirror: std::env::var(env_vars::VP_NODE_DIST_MIRROR).ok(),
140140
is_ci: std::env::var("CI").is_ok(),
141141
bypass_shim: std::env::var(env_vars::VP_BYPASS).is_ok(),
142142
debug_shim: std::env::var(env_vars::VP_DEBUG_SHIM).is_ok(),

crates/vite_shared/src/env_vars.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub const NPM_CONFIG_REGISTRY: &str = "npm_config_registry";
2525
pub const NPM_CONFIG_REGISTRY_UPPER: &str = "NPM_CONFIG_REGISTRY";
2626

2727
/// Node.js distribution mirror URL for downloads.
28-
pub const VITE_NODE_DIST_MIRROR: &str = "VITE_NODE_DIST_MIRROR";
28+
pub const VP_NODE_DIST_MIRROR: &str = "VP_NODE_DIST_MIRROR";
2929

3030
/// Override Node.js version (takes highest priority in version resolution).
3131
pub const VP_NODE_VERSION: &str = "VP_NODE_VERSION";

docs/guide/env.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,18 @@ vp env list-remote --lts # List only LTS versions
8282
vp env exec --node lts npm i # Execute npm with latest LTS
8383
vp env exec node -v # Use shim mode with automatic version resolution
8484
```
85+
86+
## Custom Node.js Mirror
87+
88+
By default, Vite+ downloads Node.js from `https://nodejs.org/dist`. If you're behind a corporate proxy or need to use an internal mirror (e.g., Artifactory), set the `VP_NODE_DIST_MIRROR` environment variable:
89+
90+
```bash
91+
# Install a specific version from your custom mirror
92+
VP_NODE_DIST_MIRROR=https://my-mirror.example.com/nodejs/dist vp env install 22
93+
94+
# Set the global default version using a custom mirror
95+
VP_NODE_DIST_MIRROR=https://my-mirror.example.com/nodejs/dist vp env default lts
96+
97+
# Set it permanently in your shell profile (.bashrc, .zshrc, etc.)
98+
echo 'export VP_NODE_DIST_MIRROR=https://my-mirror.example.com/nodejs/dist' >> ~/.zshrc
99+
```

rfcs/js-runtime.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -434,10 +434,10 @@ https://nodejs.org/dist/v{version}/node-v{version}-{platform}.{ext}
434434

435435
### Custom Mirror Support
436436

437-
The distribution URL can be overridden using the `VITE_NODE_DIST_MIRROR` environment variable. This is useful for corporate environments or regions where nodejs.org might be slow or blocked.
437+
The distribution URL can be overridden using the `VP_NODE_DIST_MIRROR` environment variable. This is useful for corporate environments or regions where nodejs.org might be slow or blocked.
438438

439439
```bash
440-
VITE_NODE_DIST_MIRROR=https://example.com/mirrors/node vp build
440+
VP_NODE_DIST_MIRROR=https://example.com/mirrors/node vp build
441441
```
442442

443443
The mirror URL should have the same directory structure as the official distribution. Trailing slashes are automatically trimmed.
@@ -680,7 +680,7 @@ pub enum Error {
680680
4. ✅ Handles concurrent downloads safely
681681
5. ✅ Returns version and binary path
682682
6. ✅ Comprehensive test coverage
683-
7. ✅ Custom mirrors via `VITE_NODE_DIST_MIRROR` environment variable
683+
7. ✅ Custom mirrors via `VP_NODE_DIST_MIRROR` environment variable
684684
8. ✅ Support `devEngines.runtime` from package.json
685685
9. ✅ Support semver ranges (^, ~, etc.) with version resolution
686686
10. ✅ Version index caching with 1-hour TTL

0 commit comments

Comments
 (0)