common/scripts/install-run.js
function getNpmPath() {
    if (!_npmPath) {
        try {
            if (os.platform() === 'win32') {
                // We're on Windows
                const whereOutput = childProcess.execSync('where npm', { stdio: [] }).toString();
                const lines = whereOutput.split(os.EOL).filter((line) => !!line);
                // take the last result, we are looking for a .cmd command
                // see https://github.com/Microsoft/web-build-tools/issues/759
                _npmPath = lines[lines.length - 1];
            }
            else {
                // We aren't on Windows - assume we're on *NIX or Darwin
                _npmPath = childProcess.execSync('which npm', { stdio: [] }).toString();
            }
        }
        catch (e) {
            throw new Error(`Unable to determine the path to the NPM tool: ${e}`);
        }
        _npmPath = _npmPath.trim();
        if (!fs.existsSync(_npmPath)) {
            throw new Error('The NPM executable does not exist');
        }
    }
    return _npmPath;
}
function getNpmPath() {
    if (!_npmPath) {
        try {
            if (os.platform() === 'win32') {
                // We're on Windows
                const whereOutput = childProcess.execSync('where npm', { stdio: [] }).toString();
                const lines = whereOutput.split(os.EOL).filter((line) => !!line);
                // take the last result, we are looking for a .cmd command
                // see https://github.com/Microsoft/web-build-tools/issues/759
                _npmPath = lines[lines.length - 1];
            }
            else {
                // We aren't on Windows - assume we're on *NIX or Darwin
                _npmPath = childProcess.execSync('which npm', { stdio: [] }).toString();
            }
        }
        catch (e) {
            throw new Error(`Unable to determine the path to the NPM tool: ${e}`);
        }
        _npmPath = _npmPath.trim();
        if (!fs.existsSync(_npmPath)) {
            throw new Error('The NPM executable does not exist');
        }
    }
    return _npmPath;
}
function getNpmPath ( ) { if ( ! _npmPath ) { try { if ( os . platform ( ) === 'win32' ) { // We're on Windows
 const whereOutput = childProcess . execSync ( 'where npm' , { stdio : [ ] } ) . toString ( ) ; const lines = whereOutput . split ( os . EOL ) . filter ( ( line ) => ! ! line ) ; // take the last result, we are looking for a .cmd command
 // see https://github.com/Microsoft/web-build-tools/issues/759
 _npmPath = lines [ lines . length - 1 ] ; } else { // We aren't on Windows - assume we're on *NIX or Darwin
 _npmPath = childProcess . execSync ( 'which npm' , { stdio : [ ] } ) . toString ( ) ; } } catch ( e ) { throw new Error ( ` ${ e } ` ) ; } _npmPath = _npmPath . trim ( ) ; if ( ! fs . existsSync ( _npmPath ) ) { throw new Error ( 'The NPM executable does not exist' ) ; } } return _npmPath ; }
Get the absolute path to the npm executable
Get the absolute path to the npm executable