vuejs/vue-cli · error · Error

Can't find ${packageName} in node_modules. Please install th

Error message

Can't find ${packageName} in node_modules. Please install the dependencies first.
Or to force upgrade, you can specify your current plugin version with the --from option

What it means

Thrown by Upgrader.upgrade when the plugin is listed in package.json but is not actually installed in node_modules (getInstalledVersion returns null/undefined). The upgrader needs to know the currently installed version to compute the upgrade; it suggests using --from to override.

Source

Thrown at packages/@vue/cli/lib/Upgrader.js:71

  async upgrade (pluginId, options) {
    const packageName = resolvePluginId(pluginId)

    let depEntry, required
    for (const depType of ['dependencies', 'devDependencies', 'optionalDependencies']) {
      if (this.pkg[depType] && this.pkg[depType][packageName]) {
        depEntry = depType
        required = this.pkg[depType][packageName]
        break
      }
    }
    if (!required) {
      throw new Error(`Can't find ${chalk.yellow(packageName)} in ${chalk.yellow('package.json')}`)
    }

    const installed = options.from || this.pm.getInstalledVersion(packageName)
    if (!installed) {
      throw new Error(
        `Can't find ${chalk.yellow(packageName)} in ${chalk.yellow('node_modules')}. Please install the dependencies first.\n` +
        `Or to force upgrade, you can specify your current plugin version with the ${chalk.cyan('--from')} option`
      )
    }

    let targetVersion = options.to || 'latest'
    // if the targetVersion is not an exact version
    if (!/\d+\.\d+\.\d+/.test(targetVersion)) {
      if (targetVersion === 'latest') {
        logWithSpinner(`Getting latest version of ${packageName}`)
      } else {
        logWithSpinner(`Getting max satisfying version of ${packageName}@${options.to}`)
      }

      targetVersion = await this.pm.getRemoteVersion(packageName, targetVersion)
      if (!options.to && options.next) {
        const next = await this.pm.getRemoteVersion(packageName, 'next')
        if (next) {

View on GitHub (pinned to 7eb93c169c)

Solutions

  1. Run npm install (or yarn install / pnpm install) first to populate node_modules.
  2. If install is failing or you know the version, use the --from flag: vue upgrade <plugin> --from <current-version>.
  3. Delete node_modules and package-lock.json, then reinstall cleanly.

Example fix

# before
$ vue upgrade @vue/cli-plugin-babel  # node_modules missing
# after
$ npm install
$ vue upgrade @vue/cli-plugin-babel
# or force
$ vue upgrade @vue/cli-plugin-babel --from 4.5.0
Defensive patterns

Strategy: validation

Validate before calling

const { existsSync } = require('fs');
const path = require('path');
if (!existsSync(path.join('node_modules', packageName, 'package.json'))) {
  console.error(`${packageName} not installed. Run: npm install`);
}

Try / catch

try {
  await upgrader.upgrade(pluginId, options);
} catch (e) {
  if (e.message.includes("node_modules")) {
    console.error('Run npm install first, or use --from to specify current version.');
    process.exit(1);
  }
  throw e;
}

Prevention

When it happens

Trigger: Running `vue upgrade <plugin>` after package.json was edited but `npm install` was never run, or after node_modules was deleted. Also when the dependency is listed but node_modules is corrupted or partially installed.

Common situations: Fresh clone where dependencies haven't been installed yet, or after a failed/partial npm install. CI environment that restores package.json but not node_modules.

Related errors


AI-assisted analysis of vuejs/vue-cli@7eb93c169c (2026-08-13). Data as JSON: /api/errors/d961e701d8c9525f. Report an issue: GitHub.