Skip to content

Commit

Permalink
fix: use realpathSync for node <16.18 on windows (#12971)
Browse files Browse the repository at this point in the history
  • Loading branch information
bluwy committed Apr 24, 2023
1 parent ada7cd5 commit 965839c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/vite/src/node/utils.ts
Expand Up @@ -586,6 +586,13 @@ function windowsSafeRealPathSync(path: string): string {
}

function optimizeSafeRealPathSync() {
// Skip if using Node <16.18 due to MAX_PATH issue: https://github.com/vitejs/vite/issues/12931
const nodeVersion = process.versions.node.split('.').map(Number)
if (nodeVersion[0] < 16 || (nodeVersion[0] === 16 && nodeVersion[1] < 18)) {
safeRealpathSync = fs.realpathSync
return
}

exec('net use', (error, stdout) => {
if (error) return
const lines = stdout.split('\n')
Expand Down

0 comments on commit 965839c

Please sign in to comment.