diff --git a/docs/guide/local-cli.md b/docs/guide/local-cli.md index f08818016a..e40219707e 100644 --- a/docs/guide/local-cli.md +++ b/docs/guide/local-cli.md @@ -87,6 +87,27 @@ overrides: ::: +::: warning Existing direct dependencies with npm +If your npm project already lists `vite` in `dependencies` or `devDependencies`, change that entry to the same alias as `overrides.vite`. npm requires a direct dependency and its override to use the [same dependency specification](https://docs.npmjs.com/cli/v11/configuring-npm/package-json/#overrides). Otherwise, `npm install` fails with `EOVERRIDE`. + +For example, update an existing `vite` development dependency as follows. Keep the other dependencies in your manifest: + +```json [package.json] +{ + "devDependencies": { + "vite": "npm:@voidzero-dev/vite-plus-core@", + "vite-plus": "" + }, + "overrides": { + "vite": "npm:@voidzero-dev/vite-plus-core@", + "vitest": "" + } +} +``` + +If you also declare `vitest` directly, set its dependency entry to the exact version in `overrides.vitest`. Run `npm install` after these changes to update the lockfile and installed dependencies. +::: + ::: details Why are these settings needed? Dependencies and plugins can import `vite` or `vitest` directly, even when your own code imports from `vite-plus`. These overrides align their dependencies with the toolchain Vite+ uses: