vite: Vite failed with projects involving cross drive links on Windows

Describe the bug

For some reasons, I have my users dir (C:\Users) linked to another dir (D:\Users) on another disk. When I start the dev server of a project at C:\Users\lihe07\Desktop\solidjs-template, vite is not working properly and some errors pops out at the console: img1

However, the dev server started at D:\Users\lihe07\Desktop\solidjs-template can work properly, and give the expected output:

img2

I have also tried a vue project and the result is similar.

It also fails when I tried to build the project npm run build and the log can be found below.

Reproduction

https://github.com/lihe07/solidjs-template

Steps to reproduce

Actually almost every vite projects in this condition can reproduce the issue:

  1. Make a soft link of the project / the parent dir of the project mklink /J DEST SRC
  2. cd, and do npm i
  3. run npm run dev or npm run build and the issue will emerge

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (8) x64 Intel(R) Xeon(R) CPU E3-1241 v3 @ 3.50GHz
    Memory: 7.34 GB / 15.96 GB
  Binaries:
    Node: 19.0.1 - C:\Program Files\nodejs\node.EXE
    npm: 8.19.2 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (21.1.0), Chromium (21.1.0), ChromiumDev (21.1.0)
    Internet Explorer: 11.0.19041.1566
  npmPackages:
    vite: ^3.2.2 => 3.2.2

Used Package Manager

npm

Logs

Logs

solidjs-template@0.0.0 build vite build --debug

vite:config bundled config file loaded in 588.18ms +0ms vite:esbuild init tsconfck (root: C:/Users/lihe07/Desktop/solid-demo) +0ms vite:esbuild init tsconfck (root: C:/Users/lihe07/Desktop/solid-demo) +3ms vite:esbuild init tsconfck (root: C:/Users/lihe07/Desktop/solid-demo) +1ms vite:esbuild init tsconfck (root: C:/Users/lihe07/Desktop/solid-demo) +0ms vite:esbuild init tsconfck end +16ms vite:esbuild init tsconfck end +1ms vite:esbuild init tsconfck end +0ms vite:esbuild init tsconfck end +0ms vite:config using resolved config: { vite:config plugins: [ vite:config ‘vite:build-metadata’, vite:config ‘vite:pre-alias’, vite:config ‘alias’, vite:config ‘solid’, vite:config ‘unocss:transformers:pre’, vite:config ‘unocss:global:build:scan’, vite:config ‘vite:modulepreload-polyfill’, vite:config ‘vite:resolve’, vite:config ‘vite:html-inline-proxy’, vite:config ‘vite:css’, vite:config ‘vite:esbuild’, vite:config ‘vite:json’, vite:config ‘vite:wasm-helper’, vite:config ‘vite:worker’, vite:config ‘vite:asset’, vite:config ‘unocss:config’, vite:config ‘unocss:transformers:default’, vite:config ‘unocss:devtools’, vite:config ‘vite:wasm-fallback’, vite:config ‘vite:define’, vite:config ‘vite:css-post’, vite:config ‘vite:build-html’, vite:config ‘vite:worker-import-meta-url’, vite:config ‘vite:asset-import-meta-url’, vite:config ‘vite:force-systemjs-wrap-complete’, vite:config ‘vite:watch-package-data’, vite:config ‘commonjs’, vite:config ‘vite:data-uri’, vite:config ‘vite:dynamic-import-vars’, vite:config ‘vite:import-glob’, vite:config ‘unocss:transformers:post’, vite:config ‘unocss:global:build:generate’, vite:config ‘vite:build-import-analysis’, vite:config ‘vite:esbuild-transpile’, vite:config ‘vite:terser’, vite:config ‘vite:reporter’, vite:config ‘vite:load-fallback’ vite:config ], vite:config build: { vite:config target: ‘esnext’, vite:config cssTarget: ‘esnext’, 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 minify: ‘esbuild’, vite:config terserOptions: {}, vite:config write: true, vite:config emptyOutDir: null, vite:config copyPublicDir: true, vite:config manifest: false, vite:config lib: false, vite:config ssr: false, vite:config ssrManifest: false, vite:config reportCompressedSize: true, vite:config chunkSizeWarningLimit: 500, vite:config watch: null, vite:config commonjsOptions: { include: [Array], extensions: [Array] }, vite:config dynamicImportVarsOptions: { warnOnError: true, exclude: [Array] }, vite:config modulePreload: { polyfill: true } vite:config }, vite:config optimizeDeps: { vite:config disabled: ‘build’, vite:config force: undefined, vite:config include: [], vite:config exclude: [], vite:config esbuildOptions: { preserveSymlinks: false } vite:config }, vite:config resolve: { vite:config mainFields: [ ‘module’, ‘jsnext:main’, ‘jsnext’ ], vite:config browserField: true, vite:config conditions: [ ‘solid’ ], vite:config extensions: [ vite:config ‘.mjs’, ‘.js’, vite:config ‘.mts’, ‘.ts’, vite:config ‘.jsx’, ‘.tsx’, vite:config ‘.json’ vite:config ], vite:config dedupe: [], vite:config preserveSymlinks: false, vite:config alias: [ [Object], [Object], [Object] ] vite:config }, vite:config esbuild: { include: /.ts$/ }, vite:config ssr: { vite:config format: ‘esm’, vite:config target: ‘node’, vite:config noExternal: [], vite:config external: [], vite:config optimizeDeps: { disabled: true, esbuildOptions: [Object] } vite:config }, vite:config configFile: ‘C:/Users/lihe07/Desktop/solid-demo/vite.config.js’, vite:config configFileDependencies: [ ‘C:/Users/lihe07/Desktop/solid-demo/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 optimizeDeps: { force: undefined }, vite:config build: {} vite:config }, vite:config root: ‘C:/Users/lihe07/Desktop/solid-demo’, vite:config base: ‘/’, vite:config publicDir: ‘C:\Users\lihe07\Desktop\solid-demo\public’, vite:config cacheDir: ‘C:\Users\lihe07\Desktop\solid-demo\node_modules\.vite’, vite:config command: ‘build’, vite:config mode: ‘production’, vite:config isWorker: false, vite:config mainConfig: null, vite:config isProduction: true, vite:config server: { vite:config preTransformRequests: true, vite:config middlewareMode: false, vite:config fs: { strict: true, allow: [Array], deny: [Array] } vite:config }, vite:config preview: { vite:config port: undefined, vite:config strictPort: undefined, vite:config host: undefined, vite:config https: undefined, vite:config open: undefined, vite:config proxy: undefined, vite:config cors: undefined, vite:config headers: undefined vite:config }, vite:config env: { BASE_URL: ‘/’, MODE: ‘production’, DEV: false, PROD: true }, vite:config assetsInclude: [Function: assetsInclude], vite:config logger: { vite:config hasWarned: false, vite:config info: [Function: info], vite:config warn: [Function: warn], vite:config warnOnce: [Function: warnOnce], vite:config error: [Function: error], vite:config clearScreen: [Function: clearScreen], vite:config hasErrorLogged: [Function: hasErrorLogged] vite:config }, vite:config packageCache: Map(0) { set: [Function (anonymous)] }, vite:config createResolver: [Function: createResolver], vite:config worker: { vite:config format: ‘iife’, vite:config plugins: [ vite:config ‘vite:build-metadata’, vite:config ‘vite:pre-alias’, vite:config ‘alias’, vite:config ‘vite:modulepreload-polyfill’, vite:config ‘vite:resolve’, vite:config ‘vite:html-inline-proxy’, vite:config ‘vite:css’, vite:config ‘vite:esbuild’, vite:config ‘vite:json’, vite:config ‘vite:wasm-helper’, vite:config ‘vite:worker’, vite:config ‘vite:asset’, vite:config ‘vite:wasm-fallback’, vite:config ‘vite:define’, vite:config ‘vite:css-post’, vite:config ‘vite:build-html’, vite:config ‘vite:worker-import-meta-url’, vite:config ‘vite:asset-import-meta-url’, vite:config ‘vite:force-systemjs-wrap-complete’, vite:config ‘vite:watch-package-data’, vite:config ‘commonjs’, vite:config ‘vite:data-uri’, vite:config ‘vite:dynamic-import-vars’, vite:config ‘vite:import-glob’, vite:config ‘vite:build-import-analysis’, vite:config ‘vite:esbuild-transpile’, vite:config ‘vite:terser’, vite:config ‘vite:reporter’, vite:config ‘vite:load-fallback’ vite:config ], vite:config rollupOptions: {}, vite:config getSortedPlugins: [Function: getSortedPlugins], vite:config getSortedPluginHooks: [Function: getSortedPluginHooks] vite:config }, vite:config appType: ‘spa’, vite:config experimental: { importGlobRestoreExtension: false, hmrPartialAccept: false }, vite:config getSortedPlugins: [Function: getSortedPlugins], vite:config getSortedPluginHooks: [Function: getSortedPluginHooks] vite:config } +472ms vite v3.2.2 building for production… ✓ 7 modules transformed. rendering chunks (1)…[vite:build-html] The “fileName” or “name” properties of emitted files must be strings that are neither absolute nor relative paths, received “D:/Users/lihe07/Desktop/solid-demo/index.html”. error during build: Error: The “fileName” or “name” properties of emitted files must be strings that are neither absolute nor relative paths, received “D:/Users/lihe07/Desktop/solid-demo/index.html”. at error (file:///D:/Users/lihe07/Desktop/solid-demo/node_modules/_rollup@2.79.1@rollup/dist/es/shared/rollup.js:1858:30) at FileEmitter.emitFile (file:///D:/Users/lihe07/Desktop/solid-demo/node_modules/_rollup@2.79.1@rollup/dist/es/shared/rollup.js:22335:24) at Object.generateBundle (file:///D:/Users/lihe07/Desktop/solid-demo/node_modules/_vite@3.2.2@vite/dist/node/chunks/dep-c842e491.js:44203:22) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async Bundle.generate (file:///D:/Users/lihe07/Desktop/solid-demo/node_modules/_rollup@2.79.1@rollup/dist/es/shared/rollup.js:15796:9) at async file:///D:/Users/lihe07/Desktop/solid-demo/node_modules/_rollup@2.79.1@rollup/dist/es/shared/rollup.js:23795:27 at async catchUnfinishedHookActions (file:///D:/Users/lihe07/Desktop/solid-demo/node_modules/_rollup@2.79.1@rollup/dist/es/shared/rollup.js:23126:20) at async doBuild (file:///D:/Users/lihe07/Desktop/solid-demo/node_modules/_vite@3.2.2@vite/dist/node/chunks/dep-c842e491.js:46588:22) at async build (file:///D:/Users/lihe07/Desktop/solid-demo/node_modules/_vite@3.2.2@vite/dist/node/chunks/dep-c842e491.js:46416:16) at async CAC.<anonymous> (file:///D:/Users/lihe07/Desktop/solid-demo/node_modules/_vite@3.2.2@vite/dist/node/cli.js:756:9)

Validations

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 12
  • Comments: 15 (2 by maintainers)

Most upvoted comments

This prevented me from moving from webpack to vite

skill issue honestly

Sorry the above message. It’s resolved by setting resolve.preserveSymlinks to true, works like a charm.

Edit: Originally thought there was a Node bug, but it’s really a naming/documentation issue causing confusion.

The problem is the promises based version of “realpath” is really for “realpath.native”! It’s mentioned in the documentation but it’s easy to overlook.

fs.realpath('T:', (e,r) => console.log(r)) // Gives "T:\\"
fs.realpath.native('T:', (e,r) => console.log(r)) // Gives "\\\\ServerName\\\MountedDirectory"
fs.realpathSync('T:') // Gives "T:\\"
fs.realpathSync.native('T:') // Gives "\\\\ServerName\\\MountedDirectory"

// The problem
await fs.promises.realpath('T:') // Gives "\\\\ServerName\\\MountedDirectory"

This prevented me from moving from webpack to vite

So the cause has been known for over half a year.

Unfortunately, there are multiple different problems. My issue, which deals with network drives is caused by fs.promises.realpath. Then there’s normalizePath and similar not handling certain strings and producing garbage.

I can’t fix it during work hours without getting approval to contribute to an Open Source project, and the issue’s I’m experiencing are solely related to the work environment. No one sane who has a choice does development with source code on a network share.

So the cause has been known for over half a year. It this issue expected to be fixed any time soon? Doesn’t seem like it should be difficult to someone familiar with contributing to vite?