-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pre-bundling dependencies,the path auto add ./ on head #4635
Comments
No problem on my mac. It looks like a windows only problem. |
yes,sure,but |
I don't see any errors on Win10/Node14 |
System: I also didn't reproduce the problem on windows 10. |
@Allenscript I'm having the same issue, and I think I know why. It looks like there is a mapping of your directory D:/code/Solution/front to the directory C:/Users/Administrator/Desktop/code/Solution/front and that's what is tripping up vite. Can you type subst in a terminal and let me know what you see? If you cd into C:/Users/Administrator/Desktop/code/Solution/front everything should work just fine. |
To reproduce the issue: cd somedir
subst X: %CD%
X:
npm init vite@latest
# Project-Name: "vite-project"
# Framework: "vue"
# Variant: "vue"
cd vite-project
npm install
npm run dev The issue does not happen with vanilla, but happens additionally with react and lit. |
Hey peeps, I've got the exact same issue here (Svelte, in my case, doesn't build on a I think I've managed to narrow down the issue to this specific plugin: vite/packages/vite/src/node/optimizer/esbuildDepPlugin.ts Lines 156 to 163 in 7977e92
The
I can see 2 possible solutions here:
let relativePath = normalizePath(path.relative(root, entryFile))
if (
!relativePath.startsWith('./') &&
!relativePath.startsWith('../') &&
relativePath !== '.' &&
!path.isAbsolute(relativePath) // <-- add this check
) {
relativePath = `./${relativePath}`
} |
On Windows, when a folder is on a virtual drive (e.g. `subst X: C:/dev`), then symlink resolving will end up causing the root of the project and the imported files to be on separate drives. This leads into a situations where `path.relative(root, entryFile)` does not return a relative path. Updates vitejs#4635
On Windows, when a folder is on a virtual drive (e.g. `subst X: C:/dev`), then symlink resolving will end up causing the root of the project and the imported files to be on separate drives. This leads into a situations where `path.relative(root, entryFile)` does not return a relative path. Updates vitejs#4635
@jemhuntr thanks, I somehow missed that issue. I created a PR for it.
There's no guarantee that subfolders of a project aren't symlinked, causing similar problems. Overall if you are using |
Note, one workaround for the problem is to use a
|
Thanks for the PR, and the workaround is much appreciated! |
yes,i run it, but it have not any thing out |
This may be a duplicate of #4302 and #10802. But given the code pointed by #4635 (comment) is removed (we now let esbuild handle that logic), I think we can close this for now. If it happens again, feel free to re-open an issue or leave a comment in #10802 |
Describe the bug
when exec npm run dev , on vite pre-bundling dependencies,it throw err, it auto add './' to the head of module path,like
dep:Vuex:1:14: error: Could not resolve "./D:/code/Solution/front/node_modules/vuex/dist/vuex.esm-bundler.js"
Reproduction
https://github.com/Allenscript/vite_demo
System Info
Used Package Manager
npm
Logs
Validations
The text was updated successfully, but these errors were encountered: