Skip to content
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

Vite resolves paths to fs root instead of root in config #2051

Closed
3 tasks done
joakimbeng opened this issue Feb 17, 2021 · 1 comment
Closed
3 tasks done

Vite resolves paths to fs root instead of root in config #2051

joakimbeng opened this issue Feb 17, 2021 · 1 comment

Comments

@joakimbeng
Copy link

⚠️ IMPORTANT ⚠️ Please check the following list before proceeding. If you ignore this issue template, your issue will be directly closed.

  • Read the docs.
  • Use Vite >=2.0. (1.x is no longer supported)
  • If the issue is related to 1.x -> 2.0 upgrade, read the Migration Guide first.

Describe the bug

Browsing to a URL path that corresponds to an existing path relative to the file system root crashes Vite.
I.e. on a unix based file system going to http://localhost:3000/home tries to read the folder /home as a file, and going to http://localhost:3000/dev tries to read /dev as a file, instead of going to the index.html fallback.

This happens in v2.0.0 but not in v2.0.0-beta.70 or below.

Reproduction

https://github.com/joakimbeng/vite-crash

System Info

  • vite version: v2.0.0
  • Operating System: macOS Catalina 10.15.6
  • Node version: v14.15.1
  • Package manager (npm/yarn/pnpm) and version: v6.14.8

Logs (Optional if provided reproduction)

`vite --debug` output

vite:config bundled config file loaded in 69ms +0ms
vite:config using resolved config: {
vite:config root: '/Users/joakim/Dev/@joakimbeng/vite-crash/src',
vite:config server: {},
vite:config configFile: '/Users/joakim/Dev/@joakimbeng/vite-crash/vite.config.js',
vite:config inlineConfig: {
vite:config root: undefined,
vite:config base: undefined,
vite:config mode: undefined,
vite:config configFile: undefined,
vite:config logLevel: undefined,
vite:config clearScreen: undefined,
vite:config server: {}
vite:config },
vite:config base: '/',
vite:config resolve: { dedupe: undefined, alias: [ [Object] ] },
vite:config publicDir: '/Users/joakim/Dev/@joakimbeng/vite-crash/src/public',
vite:config command: 'serve',
vite:config mode: 'development',
vite:config isProduction: false,
vite:config optimizeCacheDir: '/Users/joakim/Dev/@joakimbeng/vite-crash/node_modules/.vite',
vite:config plugins: [
vite:config 'vite:pre-alias',
vite:config 'alias',
vite:config 'vite:dynamic-import-polyfill',
vite:config 'vite:resolve',
vite:config 'vite:html',
vite:config 'vite:css',
vite:config 'vite:esbuild',
vite:config 'vite:json',
vite:config 'vite:wasm',
vite:config 'vite:worker',
vite:config 'vite:asset',
vite:config 'vite:define',
vite:config 'vite:css-post',
vite:config 'vite:client-inject',
vite:config 'vite:import-analysis'
vite:config ],
vite:config build: {
vite:config target: [ 'es2019', 'edge16', 'firefox60', 'chrome61', 'safari11' ],
vite:config polyfillDynamicImport: true,
vite:config outDir: 'dist',
vite:config assetsDir: 'assets',
vite:config assetsInlineLimit: 4096,
vite:config cssCodeSplit: true,
vite:config sourcemap: false,
vite:config rollupOptions: {},
vite:config commonjsOptions: { include: [Array], extensions: [Array] },
vite:config minify: 'terser',
vite:config terserOptions: {},
vite:config cleanCssOptions: {},
vite:config write: true,
vite:config emptyOutDir: null,
vite:config manifest: false,
vite:config lib: false,
vite:config ssr: false,
vite:config ssrManifest: false,
vite:config brotliSize: true,
vite:config chunkSizeWarningLimit: 500
vite:config },
vite:config env: { BASE_URL: '/', MODE: 'development', DEV: true, PROD: false },
vite:config assetsInclude: [Function: assetsInclude],
vite:config logger: {
vite:config hasWarned: false,
vite:config info: [Function: info],
vite:config warn: [Function: warn],
vite:config error: [Function: error],
vite:config clearScreen: [Function: clearScreen]
vite:config },
vite:config createResolver: [Function: createResolver]
vite:config } +5ms
vite:deps Hash is consistent. Skipping. Use --force to override. +0ms

⚡ Vite dev server running at:

Local: http://localhost:3000/
Network: http://192.168.72.29:3000/

ready in 253ms.

vite:resolve 1ms /dev -> null +0ms
vite:load 2ms [fs] /dev +0ms
10:55:29 AM [vite] Internal server error: Failed to parse source for import analysis because the content contains invalid JS syntax. If you are using JSX, make sure to name the file with the .jsx or .tsx extension.
Plugin: vite:import-analysis
File: /dev
5 | ptyv3ip
ttyv4ip
ttyv5ipptyv5ipttyv6ipptyv6ipttyv7ipptyv7ipttyv8ipptyv8ipttyv9ipptyv9ipttyvaipptyvaipttyvbipptyvbipttyvcipptyvcipttyvdipptyvdipttyveip ptyveip!ttyvfip"ptyvfip#ttyw0ip$ptyw0ip%ttyw1ip&ptyw1ip'ttyw2ip(ptyw2ip)ttyw3ip*ptyw3ip+ttyw4ip,ptyw4ip-ttyw5ip.ptyw5ip/ttyw6ip0ptyw6ip1ttyw7ip2ptyw7ip3ttyw8ip4ptyw8ip5ttyw9ip6ptyw9ip7ttywaip8ptywaip9ttywbip:ptywbip;ttywcip<ptywcip=ttywdip>ptywdip?ttyweip@ptyweipAttywfipBptywfipCptmxipDbpf0ipEbpf1ipFbpf2ipGbpf3ipfseventsonIrandomsJurandomKdtraceL
dtracehelperlockstatperN
sdtsystraceperP machtraceerQ
fbtRprofileS
6 | afsc_type5rTdisk0ypUrdisk0pVdisk0s1rdisk0s15rXdisk0s2rdisk0s25rZdisk1s2[rdisk12\disk1s1rdisk1s15r^disk1s2rdisk1s25r`disk1s3rdisk1s35rbdisk1s5rdisk1s55rddisk1s4rdisk1s45rgxcpm1s4iio8log4io8logmt5rm
autofs_nowaitsautofs_notriggeru autofs_homedirmounterwautofs_controloy
HAX{ uart.BLTHtr}$cu.Bluetooth-Incoming-Port�$ty.Bluetooth-Incoming-Port?nsmb0ue�bpf4ue�ttys002�ttys003�ttys004�ttys005�ttys006�ttys007�ttys008�ttys009�ttys010�ttys011ttys012ttys013 ttys014
ttys016ttys017ttys000ttys001udisk21wrdisk2ydisk2s2rdisk2s2oot}disk2s1rdisk2s1oot!"kbfuse0#"kbfuse1%"kbfuse2'"kbfuse3)"kbfuse4+"kbfuse5-"kbfuse6/"kbfuse71"kbfuse83"kbfuse95kbfuse10oot7kbfuse11oot9kbfuse12oot;kbfuse13oot=kbfuse14oot?kbfuse15ootAkbfuse16ootCkbfuse17ootEkbfuse18ootGkbfuse19ootIkbfuse20ootKkbfuse21ootMkbfuse22ootOkbfuse23ootQkbfuse24ootSkbfuse25ootUkbfuse26ootWkbfuse27ootYkbfuse28oot[kbfuse29oot]kbfuse30oot_kbfuse31ootakbfuse32ootckbfuse33ootekbfuse34ootgkbfuse35ootikbfuse36ootkkbfuse37ootmkbfuse38ootokbfuse39ootqkbfuse40ootskbfuse41ootukbfuse42ootwkbfuse43ootykbfuse44oot{kbfuse45oot}kbfuse46oot�kbfuse47oot�kbfuse48oot�kbfuse49oot�kbfuse50oot�kbfuse51oot�kbfuse52oot�kbfuse53oot�kbfuse54oot�kbfuse55oot�kbfuse56oot�kbfuse57oot�kbfuse58oot�kbfuse59oot�kbfuse60oot�kbfuse61oot�kbfuse62oot�kbfuse63oot
| ^
at formatError (/Users/joakim/Dev/@joakimbeng/vite-crash/node_modules/vite/dist/node/chunks/dep-9bcbff8e.js:45689:46)
at TransformContext.error (/Users/joakim/Dev/@joakimbeng/vite-crash/node_modules/vite/dist/node/chunks/dep-9bcbff8e.js:45685:19)
at TransformContext.transform (/Users/joakim/Dev/@joakimbeng/vite-crash/node_modules/vite/dist/node/chunks/dep-9bcbff8e.js:47141:22)
at async Object.transform (/Users/joakim/Dev/@joakimbeng/vite-crash/node_modules/vite/dist/node/chunks/dep-9bcbff8e.js:45887:30)
at async transformRequest (/Users/joakim/Dev/@joakimbeng/vite-crash/node_modules/vite/dist/node/chunks/dep-9bcbff8e.js:61450:29)
at async /Users/joakim/Dev/@joakimbeng/vite-crash/node_modules/vite/dist/node/chunks/dep-9bcbff8e.js:61552:32

@joakimbeng
Copy link
Author

@yyx990803 this is still an issue in v2.0.1 browsing to http://localhost:3000/dev results in the same error

@github-actions github-actions bot locked and limited conversation to collaborators Jul 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant