gatsbyjs/gatsby · error

Something went wrong when trying to add the plugins to the p

Error message

Something went wrong when trying to add the plugins to the project: ${(e as Error).message}

What it means

Thrown by create-gatsby's addPluginsToProject helper when dynamically requiring the install-plugin command and invoking its exported addPlugins function fails. The wrapper rethrows the underlying Error message so the CLI surfaces a single actionable failure instead of a raw stack trace. It indicates the plugin-install step of `gatsby new` (or the create-gatsby CLI) could not register the selected starters/plugins into the new project.

Source

Thrown at packages/create-gatsby/src/install-plugins.ts:74

  } catch (e) {
    throw new Error(
      `Could not find a suitable version of gatsby-cli. Please report this issue at https://www.github.com/gatsbyjs/gatsby/issues`
    )
  }
}

const addPluginsToProject = async (
  installPluginCommand: string,
  plugins: Array<string>,
  pluginOptions: PluginConfigMap = {},
  rootPath: string,
  packages: Array<string>
): Promise<void> => {
  try {
    const { addPlugins } = require(installPluginCommand)
    await addPlugins(plugins, pluginOptions, rootPath, packages)
  } catch (e) {
    throw new Error(
      `Something went wrong when trying to add the plugins to the project: ${
        (e as Error).message
      }`
    )
  }
}

export async function installPlugins(
  plugins: Array<string>,
  pluginOptions: PluginConfigMap = {},
  rootPath: string,
  packages: Array<string>
): Promise<void> {
  try {
    const gatsbyPath = resolveGatsbyPath(rootPath)
    const installPluginCommand = resolveGatsbyCliPath(rootPath, gatsbyPath)

    await addPluginsToProject(

View on GitHub (pinned to 8b06340921)

Solutions

  1. Re-run `npm create gatsby` on a stable network connection and confirm the registry is reachable (npm ping / yarn info <installer-package>).
  2. Verify the installPluginCommand value resolves to a module that exports an async addPlugins(plugins, pluginOptions, rootPath, packages) function.
  3. Check the wrapped Error message embedded after the colon — it carries the root cause (EACCES, ENOTFOUND, missing export) and dictates the next step.
  4. Ensure write permissions and disk space at rootPath, and that node_modules at rootPath is not locked by another process.
  5. If using a custom/nightly installer, pin to the matching create-gatsby and installer package versions from the release notes.

Example fix

// before: passing a stale installer path
await installPlugins(plugins, opts, rootPath, packages)
// after: confirm the installer module exports addPlugins before delegating
const mod = require(installPluginCommand)
if (typeof mod.addPlugins !== 'function') {
  throw new Error(`${installPluginCommand} does not export addPlugins`)
}
await mod.addPlugins(plugins, opts, rootPath, packages)
Defensive patterns

Strategy: try-catch

Validate before calling

const mod = (() => { try { return require(installPluginCommand) } catch { return null } })()
if (!mod || typeof mod.addPlugins !== 'function') {
  // skip plugin install with a clear user message instead of letting addPluginsToProject throw
}

Type guard

const isInstallPluginModule = (m: any): m is { addPlugins: (...a: any[]) => Promise<void> } =>
  !!m && typeof m.addPlugins === 'function'

Try / catch

try {
  await addPluginsToProject(cmd, plugins, opts, root, packages)
} catch (e) {
  // message already embeds the root cause; surface to user, do not retry blindly
  report.panic('Plugin installation failed: ' + (e as Error).message)
}

Prevention

When it happens

Trigger: Calling addPluginsToProject(installPluginCommand, plugins, pluginOptions, rootPath, packages) where require(installPluginCommand) resolves to a module whose addPlugins export rejects or throws, OR the installPluginCommand path itself cannot be required (wrong path/missing export). Concretely: the create-gatsby flow selecting plugins whose installer package is not installed, network-offline yarn/npm add failing, or a plugin option shape mismatched from what addPlugins expects.

Common situations: Running `npm create gatsby` (or the create-gatsby bin) behind a flaky proxy or offline so the CMS/theme installer package fails to fetch; selecting a plugin whose install hook writes to a path without write permissions; version skew where the installer package no longer exports addPlugins; using a custom installPluginCommand pointing at a stale local file.

Related errors


AI-assisted analysis of gatsbyjs/gatsby@8b06340921 (2026-08-13). Data as JSON: /api/errors/c0a7669f587707f5. Report an issue: GitHub.