fix(pm): error retrieving .npmrc file path

This commit is contained in:
chenos 2024-04-24 23:15:34 +08:00
parent 229e5d1a40
commit 6781f28fbf

View File

@ -70,11 +70,11 @@ export function getNodeModulesPluginDir(packageName: string) {
export function getAuthorizationHeaders(registry?: string, authToken?: string) {
const headers = {};
if (registry && !authToken) {
const npmrcPath = path.join(process.cwd(), '.npmrc');
const npmrcPath = path.join(os.homedir(), '.npmrc');
const url = new URL(registry);
let envConfig: Record<string, string> = process.env;
if (fs.existsSync(npmrcPath)) {
const content = fs.readFileSync(path.join(process.cwd(), '.npmrc'), 'utf-8');
const content = fs.readFileSync(npmrcPath, 'utf-8');
envConfig = {
...envConfig,
...ini.parse(content),