mirror of
https://github.com/coreybutler/nvm-windows.git
synced 2025-09-26 15:51:33 +00:00
Added simple PATH troubleshooter
This commit is contained in:
18
utilities/pathfinder/README.md
Normal file
18
utilities/pathfinder/README.md
Normal file
@@ -0,0 +1,18 @@
|
||||
# pathfinder
|
||||
|
||||
This app is used to help identify NVM4W installation problems. The executable is not signed and is intended for troubleshooting purposes only. It is just a troubleshooting tool which is not an officially a supported part of NVM for Windows.
|
||||
|
||||
## Usage
|
||||
|
||||
Download pathfinder.exe and run it.
|
||||
|
||||
The output will look like:
|
||||
|
||||
```
|
||||
> .\pathfinder.exe
|
||||
PATH directories containing node.exe:
|
||||
|
||||
1. C:\Program Files\nodejs (NVM_SYMLINK)
|
||||
|
||||
NVM for Windows is correctly positioned in the PATH.
|
||||
```
|
48
utilities/pathfinder/src/pathfinder.js
Normal file
48
utilities/pathfinder/src/pathfinder.js
Normal file
@@ -0,0 +1,48 @@
|
||||
const paths = new Set()
|
||||
const symlinks = new Set()
|
||||
const nvm4w = new Set()
|
||||
|
||||
// Identify paths with node.exe
|
||||
const sources = new Set(Deno.env.get('PATH').split(';'))
|
||||
for (const dir of sources.values()) {
|
||||
try {
|
||||
await Deno.stat(`${dir}\\node.exe`)
|
||||
paths.add(dir)
|
||||
|
||||
const i = await Deno.lstat(dir)
|
||||
if (i.isSymlink) {
|
||||
symlinks.add(dir)
|
||||
const real = await Deno.realPath(dir)
|
||||
|
||||
try {
|
||||
await Deno.stat(`${real}\\..\\nvm.exe`)
|
||||
nvm4w.add(dir)
|
||||
} catch (e) {}
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
const directories = Array.from(paths)
|
||||
|
||||
let ok = false
|
||||
|
||||
console.log('PATH directories containing node.exe:\n')
|
||||
|
||||
for (const key in directories) {
|
||||
const dir = directories[key]
|
||||
const isnvm4w = nvm4w.has(dir)
|
||||
const i = parseInt(key, 10)
|
||||
|
||||
if (i === 0 && isnvm4w) {
|
||||
ok = true
|
||||
}
|
||||
|
||||
console.log(` ${i + 1}. ${dir}${isnvm4w ? ' (NVM_SYMLINK)' : ''}`)
|
||||
}
|
||||
|
||||
if (ok) {
|
||||
console.log('\nNVM for Windows is correctly positioned in the PATH.')
|
||||
} else {
|
||||
console.log('\nNVM for Windows is INCORRECTLY positioned in the PATH (must be first)')
|
||||
console.log('A prior/alternative installation of Node.js may be preventing NVM for Windows from functioning.')
|
||||
}
|
4
utilities/pathfinder/start.bat
Normal file
4
utilities/pathfinder/start.bat
Normal file
@@ -0,0 +1,4 @@
|
||||
@echo off
|
||||
cls
|
||||
deno run --allow-all ./src/pathfinder.js
|
||||
@echo on
|
Reference in New Issue
Block a user