@@ -205,22 +205,32 @@ export function findNpmPathSync(npmBinPath: string): string | undefined {
205205 const { WIN32 } = constants
206206 let thePath = npmBinPath
207207 while ( true ) {
208+ const libNmNpmPath = path . join ( thePath , 'lib' , NODE_MODULES , NPM )
209+ // mise puts its npm bin in a path like:
210+ // /Users/SomeUsername/.local/share/mise/installs/node/vX.X.X/bin/npm.
211+ // HOWEVER, the location of the npm install is:
212+ // /Users/SomeUsername/.local/share/mise/installs/node/vX.X.X/lib/node_modules/npm.
213+ if (
214+ // Use existsSync here because statsSync, even with { throwIfNoEntry: false },
215+ // will throw an ENOTDIR error for paths like ./a-file-that-exists/a-directory-that-does-not.
216+ // See https://github.com/nodejs/node/issues/56993.
217+ existsSync ( libNmNpmPath ) &&
218+ statSync ( libNmNpmPath , { throwIfNoEntry : false } ) ?. isDirectory ( )
219+ ) {
220+ thePath = path . join ( libNmNpmPath , NPM )
221+ }
208222 const nmPath = path . join ( thePath , NODE_MODULES )
209223 if (
210224 // npm bin paths may look like:
211- // /usr/local/share/npm/bin/npm
212- // /Users/SomeUsername/.nvm/versions/node/vX.X.X/bin/npm
213- // C:\Users\SomeUsername\AppData\Roaming\npm\bin\npm.cmd
225+ // /usr/local/share/npm/bin/npm
226+ // /Users/SomeUsername/.nvm/versions/node/vX.X.X/bin/npm
227+ // C:\Users\SomeUsername\AppData\Roaming\npm\bin\npm.cmd
214228 // OR
215- // C:\Program Files\nodejs\npm.cmd
216- //
217- // In all cases the npm path contains a node_modules folder:
218- // /usr/local/share/npm/bin/npm/node_modules
219- // C:\Program Files\nodejs\node_modules
229+ // C:\Program Files\nodejs\npm.cmd
220230 //
221- // Use existsSync here because statsSync, even with { throwIfNoEntry: false },
222- // will throw an ENOTDIR error for paths like ./a-file-that-exists/a-directory-that-does-not.
223- // See https://github.com/ nodejs/node/issues/56993.
231+ // In practically all cases the npm path contains a node_modules folder:
232+ // /usr/local/share/npm/bin/npm/node_modules
233+ // C:\Program Files\ nodejs\node_modules
224234 existsSync ( nmPath ) &&
225235 statSync ( nmPath , { throwIfNoEntry : false } ) ?. isDirectory ( ) &&
226236 // Optimistically look for the default location.
0 commit comments