function _syncNpmrc(sourceNpmrcFolder, targetNpmrcFolder) {
    const sourceNpmrcPath = path.join(sourceNpmrcFolder, '.npmrc');
    const targetNpmrcPath = path.join(targetNpmrcFolder, '.npmrc');
    try {
        if (fs.existsSync(sourceNpmrcPath)) {
            let npmrcFileLines = fs.readFileSync(sourceNpmrcPath).toString().split('\n');
            npmrcFileLines = npmrcFileLines.map((line) => (line || '').trim());
            const resultLines = [];
            // Trim out lines that reference environment variables that aren't defined
            for (const line of npmrcFileLines) {
                // This finds environment variable tokens that look like "${VAR_NAME}"
                const regex = /\$\{([^\}]+)\}/g;
                const environmentVariables = line.match(regex);
                let lineShouldBeTrimmed = false;
                if (environmentVariables) {
                    for (const token of environmentVariables) {
                        // Remove the leading "${" and the trailing "}" from the token
                        const environmentVariableName = token.substring(2, token.length - 1);
                        if (!process.env[environmentVariableName]) {
                            lineShouldBeTrimmed = true;
                            break;
                        }
                    }
                }
                if (lineShouldBeTrimmed) {
                    // Example output:
                    // "; MISSING ENVIRONMENT VARIABLE: //my-registry.com/npm/:_authToken=${MY_AUTH_TOKEN}"
                    resultLines.push('; MISSING ENVIRONMENT VARIABLE: ' + line);
                }
                else {
                    resultLines.push(line);
                }
            }
            fs.writeFileSync(targetNpmrcPath, resultLines.join(os.EOL));
        }
        else if (fs.existsSync(targetNpmrcPath)) {
            // If the source .npmrc doesn't exist and there is one in the target, delete the one in the target
            fs.unlinkSync(targetNpmrcPath);
        }
    }
    catch (e) {
        throw new Error(`Error syncing .npmrc file: ${e}`);
    }
}
As a workaround, _syncNpmrc() copies the .npmrc file to the target folder, and also trims
unusable lines from the .npmrc file.  If the source .npmrc file not exist, then _syncNpmrc()
will delete an .npmrc that is found in the target folder.

Why are we trimming the .npmrc lines?  NPM allows environment variables to be specified in
the .npmrc file to provide different authentication tokens for different registry.
However, if the environment variable is undefined, it expands to an empty string, which
produces a valid-looking mapping with an invalid URL that causes an error.  Instead,
we'd prefer to skip that line and continue looking in other places such as the user's
home directory.

IMPORTANT: THIS CODE SHOULD BE KEPT UP TO DATE WITH Utilities._syncNpmrc()