Skip to content

Commit 4117d5c

Browse files
committed
fix: clean up npm artifacts before web-bot-auth build
Removes package-lock.json and node_modules before npm install to avoid npm optional dependency resolution bugs. Ref: npm/cli#4828
1 parent 2e78ffc commit 4117d5c

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

‎pkg/extensions/webbotauth.go‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,14 @@ func buildWebBotAuthExtension(ctx context.Context, browserExtDir, hostURL, keyDa
286286
extractedDir := filepath.Dir(filepath.Dir(browserExtDir))
287287

288288
// Install dependencies
289+
// Clean up package-lock.json and node_modules first to avoid npm optional dependency bug
290+
// See: https://github.com/npm/cli/issues/4828
291+
pterm.Info.Println("Cleaning up any existing npm artifacts...")
292+
packageLockPath := filepath.Join(extractedDir, "package-lock.json")
293+
nodeModulesPath := filepath.Join(extractedDir, "node_modules")
294+
_ = os.Remove(packageLockPath)
295+
_ = os.RemoveAll(nodeModulesPath)
296+
289297
pterm.Info.Println("Installing dependencies (this may take a minute)...")
290298
npmInstall := exec.CommandContext(ctx, "npm", "install")
291299
npmInstall.Dir = extractedDir

0 commit comments

Comments
 (0)