{"record":{"id":"5228854a1791c6f3","repo":"parcel-bundler/parcel","slug":"failed-to-install-modulenames-err-message","errorCode":null,"errorMessage":"Failed to install ${moduleNames}: ${err.message}","messagePattern":"Failed to install (.+?): (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/package-manager/src/installPackage.js","lineNumber":66,"sourceCode":"    ['package.json'],\n    projectRoot,\n  );\n  let cwd = fromPkgPath ? path.dirname(fromPkgPath) : fs.cwd();\n\n  if (!packageInstaller) {\n    packageInstaller = await determinePackageInstaller(fs, from, projectRoot);\n  }\n\n  try {\n    await packageInstaller.install({\n      modules,\n      saveDev,\n      cwd,\n      packagePath: fromPkgPath,\n      fs,\n    });\n  } catch (err) {\n    throw new Error(`Failed to install ${moduleNames}: ${err.message}`);\n  }\n\n  if (installPeers) {\n    await Promise.all(\n      modules.map(m =>\n        installPeerDependencies(\n          fs,\n          packageManager,\n          m,\n          from,\n          projectRoot,\n          options,\n        ),\n      ),\n    );\n  }\n}\n","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/parcel-bundler/parcel/blob/59484858a1a0bcbb71f74088956bb437a2db6505/packages/core/package-manager/src/installPackage.js#L48-L84","documentation":"Thrown by installPackage() when the determined package installer's install() method throws. This is a generic wrapper around any installer (npm, yarn, or pnpm). The error message includes the module names being installed and the underlying installer's error message. This function is called by NodePackageManager.resolve() during auto-install and by installPeerDependencies.","triggerScenarios":"installPackage() calls packageInstaller.install() with the modules, saveDev flag, cwd, and packagePath. Any rejection from that promise is caught and re-wrapped with context about which modules failed. The determinePackageInstaller call selects npm/yarn/pnpm based on lockfile detection.","commonSituations":"Auto-install triggered by Parcel's shouldAutoInstall option fails because the package doesn't exist on the registry. Permission errors writing to node_modules. Package name typo causing a 404. SaveDev flag causes package.json write permission errors. Mixed package managers (yarn.lock present but npm is called).","solutions":["Read the inner err.message in the thrown error — it contains the installer-specific reason.","Install the package manually with the correct package manager: `npm install <module>` or `yarn add <module>`.","Disable auto-install if it's causing repeated failures: set `shouldAutoInstall: false` in Parcel config.","Ensure only one package manager is used — remove conflicting lockfiles (package-lock.json AND yarn.lock AND pnpm-lock.yaml)."],"exampleFix":"// before: auto-install fails during build\n// Error: Failed to install react: EACCES permission denied\n\n// after: install manually beforehand\n// $ npm install react\n// then run parcel build","handlingStrategy":"try-catch","validationCode":"// Pre-check: verify modules exist on registry before install\nconst {execSync} = require('child_process');\n\nfunction moduleExists(name) {\n  try {\n    execSync(`npm view ${name} version`, {stdio: 'pipe', timeout: 10000});\n    return true;\n  } catch {\n    return false;\n  }\n}\n\nfor (let mod of modules) {\n  if (!moduleExists(mod.name)) {\n    throw new Error(`Package '${mod.name}' does not exist on the registry`);\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  await installPackage(fs, packageManager, modules, from, projectRoot, options);\n} catch (e) {\n  if (e.message.startsWith('Failed to install')) {\n    // Extract module names and inner error\n    let match = e.message.match(/Failed to install (.*): (.*)/);\n    if (match) {\n      console.error(`Install of ${match[1]} failed: ${match[2]}`);\n    }\n  } else {\n    throw e;\n  }\n}","preventionTips":["Disable Parcel's auto-install (`shouldAutoInstall: false`) and manage dependencies explicitly.","Pre-install all dependencies before running Parcel build/serve.","Ensure only one lockfile exists (package-lock.json OR yarn.lock OR pnpm-lock.yaml).","Verify package names are spelled correctly in package.json."],"tags":["package-manager","install-failure","auto-install","wrapper","dependencies"],"backgroundTag":null,"analyzedSha":"59484858a1a0bcbb71f74088956bb437a2db6505","analyzedAt":"2026-08-13T04:06:35.925Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}