You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import.meta.glob("../index.html", { as: "raw" }) fails with an error like "no such file or directory, open '/home/projects/index.html'". This seems to be caused by the following line:
base is the common base (i.e. the directory root) and file is the relative path from the current file. This means that the .. is essentially applied "twice" and Vite is not able find the file.
Error: Build failed with 1 error:
html:/home/projects/vitejs-vite-pvrnsj/index.html:1:7: ERROR: [plugin: vite:dep-scan] ENOENT: no such file or directory, open '/home/projects/index.html'
at failureErrorWithLog (/home/projects/vitejs-vite-pvrnsj/node_modules/esbuild/lib/main.js:1557:15)
at eval (/home/projects/vitejs-vite-pvrnsj/node_modules/esbuild/lib/main.js:1215:28)
at runOnEndCallbacks (/home/projects/vitejs-vite-pvrnsj/node_modules/esbuild/lib/main.js:1005:63)
at buildResponseToResult (/home/projects/vitejs-vite-pvrnsj/node_modules/esbuild/lib/main.js:1213:7)
at eval (/home/projects/vitejs-vite-pvrnsj/node_modules/esbuild/lib/main.js:1322:14)
at eval (/home/projects/vitejs-vite-pvrnsj/node_modules/esbuild/lib/main.js:637:9)
at handleIncomingPacket (/home/projects/vitejs-vite-pvrnsj/node_modules/esbuild/lib/main.js:734:9)
at Socket.readFromStdout (/home/projects/vitejs-vite-pvrnsj/node_modules/esbuild/lib/main.js:604:7)
at Socket.EventEmitter.emit (https://vitejs-vite-pvrnsj.w.staticblitz.com/blitz.5bca79c80956550a0ee18f24bf5b874e18bb8626.js:6:131220)
at addChunk (https://vitejs-vite-pvrnsj.w.staticblitz.com/blitz.5bca79c80956550a0ee18f24bf5b874e18bb8626.js:6:537045)
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 https://github.com/vuejs/core instead.
The issue occurs because in await fsp.readFile(path.join(base, file), 'utf-8'), file has been manipulated to include a number of ../ (as many as parentDepth). When joining base and file, parentDepth amount of folders are stripped from base. PR #7371 suggests fixing this by using path.join(base, file[i]) instead. file[i] is the unmanipulated path relative to base that file is created from.
toshify
added a commit
to toshify/vite
that referenced
this issue
Mar 19, 2022
Describe the bug
import.meta.glob("../index.html", { as: "raw" })
fails with an error like "no such file or directory, open '/home/projects/index.html'". This seems to be caused by the following line:vite/packages/vite/src/node/importGlob.ts
Line 150 in 6bc45a2
base
is the common base (i.e. the directory root) andfile
is the relative path from the current file. This means that the..
is essentially applied "twice" and Vite is not able find the file.Reproduction
https://stackblitz.com/edit/vitejs-vite-pvrnsj?file=src/main.js
System Info
Used Package Manager
yarn
Logs
Validations
The text was updated successfully, but these errors were encountered: