Description
Describe the bug
For special reasons, I have to import some packages in absolute path, like:
import '/Users/xxx/my-project/node_modules/foo/x.js'
with config:
{
resolve: {
alias: [{
find: '/Users/xxx/my-project/node_modules/foo',
replacement: 'foo',
}]
}
}
In both Vite 5 and Vite 6 they work as expected, however, in Vite 6, it will cause a warning message like:
5:50:59 PM [vite] (client) ✨ new dependencies optimized: foo/x.js
I understand the optimize process didn't well reorganize the absolute path import as a package one at first but somehow did it later.
Repro: https://github.com/Jinjiang/reproductions/tree/vite-deps-alias-20250507-2
Even in some cases, there will be some other "file not exist" warnings like:
5:44:27 PM [vite] (client) ✨ new dependencies optimized: foo/foo1.mjs, foo/foo-a.cjs, foo/foo-b.cjs, foo/foo-c.mjs, @mdx-js/react, bar
5:44:27 PM [vite] (client) ✨ optimized dependencies changed. reloading
The file does not exist at "/<project-root>/node_modules/.vite/deps/chunk-E6KUT42S.js?v=05fb22f8" which is in the optimize deps directory. The dependency might be incompatible with the dep optimizer. Try adding it to `optimizeDeps.exclude`.
Repro: https://github.com/Jinjiang/reproductions/tree/vite-deps-alias-20250507 (sorry I can't simplify it further to keep the whole warnings on)
I'd like to understand what the difference is between Vite 5 and Vite 6, and how to avoid or skip the warning messages being printed if it's not a bug.
Thanks.
Reproduction
https://github.com/Jinjiang/reproductions/tree/vite-deps-alias-20250507-2
Steps to reproduce
How to reproduce:
pnpm install
pnpm dev
run it in VIte 5
pnpm dev:5
System Info
System:
OS: Linux 5.15 Ubuntu 22.04.3 LTS 22.04.3 LTS (Jammy Jellyfish)
CPU: (10) arm64 unknown
Memory: 5.82 GB / 7.64 GB
Container: Yes
Shell: 5.1.16 - /bin/bash
Binaries:
Node: 22.14.0 - ~/.volta/tools/image/node/22.14.0/bin/node
npm: 10.9.2 - ~/.volta/tools/image/node/22.14.0/bin/npm
pnpm: 10.9.0 - ~/.volta/bin/pnpm
Browsers:
Chromium: 135.0.7049.114
npmPackages:
@vitejs/plugin-react: ^4.4.1 => 4.4.1
Used Package Manager
pnpm
Logs
5:50:59 PM [vite] (client) ✨ new dependencies optimized: foo/foo.mjs
or:
5:44:27 PM [vite] (client) ✨ new dependencies optimized: foo/foo1.mjs, foo/foo-a.cjs, foo/foo-b.cjs, foo/foo-c.mjs, @mdx-js/react, bar
5:44:27 PM [vite] (client) ✨ optimized dependencies changed. reloading
The file does not exist at "/<project-root>/node_modules/.vite/deps/chunk-E6KUT42S.js?v=05fb22f8" which is in the optimize deps directory. The dependency might be incompatible with the dep optimizer. Try adding it to `optimizeDeps.exclude`.
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.