@@ -10,6 +10,16 @@ import { PackageNameSchema, UsernameSchema, OrgNameSchema, ScopeTeamSchema } fro
1010import { logCommand , logSuccess , logError , logDebug } from './logger.ts'
1111
1212const execFileAsync = promisify ( execFile )
13+ export const NPM_REGISTRY_URL = 'https://registry.npmjs.org/'
14+
15+ function createNpmEnv ( overrides : Record < string , string > = { } ) : Record < string , string > {
16+ return {
17+ ...process . env ,
18+ ...overrides ,
19+ FORCE_COLOR : '0' ,
20+ npm_config_registry : NPM_REGISTRY_URL ,
21+ }
22+ }
1323
1424/**
1525 * Validates an npm package name using the official npm validation package
@@ -191,10 +201,7 @@ async function execNpmInteractive(
191201 let authUrlTimeout : ReturnType < typeof setTimeout > | null = null
192202 let authUrlTimedOut = false
193203
194- const env : Record < string , string > = {
195- ...( process . env as Record < string , string > ) ,
196- FORCE_COLOR : '0' ,
197- }
204+ const env = createNpmEnv ( )
198205
199206 // When openUrls is false, tell npm not to open the browser.
200207 // npm still prints the auth URL and polls doneUrl
@@ -330,7 +337,7 @@ async function execNpm(args: string[], options: ExecNpmOptions = {}): Promise<Np
330337 // On Unix, we keep it false for better security and performance
331338 const { stdout, stderr } = await execFileAsync ( 'npm' , npmArgs , {
332339 timeout : 60000 ,
333- env : { ... process . env , FORCE_COLOR : '0' } ,
340+ env : createNpmEnv ( ) ,
334341 shell : process . platform === 'win32' ,
335342 } )
336343
@@ -606,7 +613,7 @@ export async function packageInit(
606613 const { stdout, stderr } = await execFileAsync ( 'npm' , npmArgs , {
607614 timeout : 60000 ,
608615 cwd : tempDir ,
609- env : { ... process . env , FORCE_COLOR : '0' } ,
616+ env : createNpmEnv ( ) ,
610617 shell : process . platform === 'win32' ,
611618 } )
612619
0 commit comments