1- import { existsSync , promises as fs , realpathSync , statSync } from 'node:fs'
1+ import { existsSync , promises as fs , realpathSync } from 'node:fs'
22import path from 'node:path'
33import process from 'node:process'
44
@@ -19,7 +19,7 @@ type GlobWithGitIgnoreOptions = GlobOptions & {
1919 socketConfig ?: SocketYml | undefined
2020}
2121
22- const { NODE_MODULES , NPM , shadowBinPath } = constants
22+ const { NPM , shadowBinPath } = constants
2323
2424async function filterGlobResultToSupportedFiles (
2525 entries : string [ ] ,
@@ -201,7 +201,6 @@ export function findBinPathDetailsSync(binName: string): {
201201export function findNpmPathSync ( npmBinPath : string ) : string | undefined {
202202 let thePath = npmBinPath
203203 while ( true ) {
204- const nmPath = path . join ( thePath , NODE_MODULES )
205204 if (
206205 // npm bin paths may look like:
207206 // /usr/local/share/npm/bin/npm
@@ -210,20 +209,11 @@ export function findNpmPathSync(npmBinPath: string): string | undefined {
210209 // OR
211210 // C:\Program Files\nodejs\npm.cmd
212211 //
213- // In all cases the npm path contains a node_modules folder:
214- // /usr/local/share/npm/bin/npm/node_modules
215- // C:\Program Files\nodejs\node_modules
216- //
217- // Use existsSync here because statsSync, even with { throwIfNoEntry: false },
218- // will throw an ENOTDIR error for paths like ./a-file-that-exists/a-directory-that-does-not.
219- // See https://github.com/nodejs/node/issues/56993.
220- existsSync ( nmPath ) &&
221- statSync ( nmPath , { throwIfNoEntry : false } ) ?. isDirectory ( ) &&
222212 // Optimistically look for the default location.
223- ( path . basename ( thePath ) === NPM ||
224- // Chocolatey installs npm bins in the same directory as node bins.
225- // Lazily access constants.WIN32.
226- ( constants . WIN32 && existsSync ( path . join ( thePath , `${ NPM } .cmd` ) ) ) )
213+ path . basename ( thePath ) === NPM ||
214+ // Chocolatey installs npm bins in the same directory as node bins.
215+ // Lazily access constants.WIN32.
216+ ( constants . WIN32 && existsSync ( path . join ( thePath , `${ NPM } .cmd` ) ) )
227217 ) {
228218 return thePath
229219 }
0 commit comments