Strange error with vite@beta on every other build in Yarn PnP with a nested `publicDir`
See original GitHub issueDescribe the bug
When publicDir
is set (which should copy over its contents to the build directory) and we nest its files at least 3 levels deep (public/some/folder/public-asset.all
), an error occurs every other build with yarn PnP enabled:
The "path" argument must be of type string. Received an instance of Buffer
error during build:
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received an instance of Buffer
at new NodeError (node:internal/errors:388:5)
at validateString (node:internal/validators:114:11)
at Object.isAbsolute (node:path:1157:5)
at VirtualFS.mapToBase (/repro-vite-yarn-bug/.pnp.cjs:4308:24)
at VirtualFS.rmdirSync (/repro-vite-yarn-bug/.pnp.cjs:4157:39)
at PosixFS.rmdirSync (/repro-vite-yarn-bug/.pnp.cjs:4157:24)
at URLFS.rmdirSync (/repro-vite-yarn-bug/.pnp.cjs:4157:24)
at _rmdirSync (node:internal/fs/rimraf:260:21)
at rimrafSync (node:internal/fs/rimraf:193:7)
at node:internal/fs/rimraf:253:9
Reproduction
https://github.com/IgnusG/repro-vite-yarn-bug
System Info
System:
OS: Linux 5.10 Arch Linux
CPU: (16) x64 Intel(R) Core(TM) i9-10885H CPU @ 2.40GHz
Memory: 28.93 GB / 31.23 GB
Container: Yes
Shell: 5.9 - /bin/zsh
Binaries:
Node: 18.4.0 - ~/.asdf/shims/node
Yarn: 3.2.1 - ~/.asdf/shims/yarn
npm: 8.7.0 - ~/.asdf/shims/npm
Used Package Manager
yarn
Logs
Click to expand!
vite:config bundled config file loaded in 38.84ms +0ms vite:config using resolved config: { vite:config publicDir: '/oss/repro-vite-yarn-bug/public', vite:config build: { vite:config target: [ 'es2020', 'edge88', 'firefox78', 'chrome87', 'safari13' ], vite:config polyfillModulePreload: true, vite:config outDir: 'dist', vite:config assetsDir: 'assets', vite:config assetsInlineLimit: 4096, vite:config cssCodeSplit: false, vite:config cssTarget: [ 'es2020', 'edge88', 'firefox78', 'chrome87', 'safari13' ], vite:config sourcemap: false, vite:config rollupOptions: {}, vite:config minify: 'esbuild', vite:config terserOptions: {}, vite:config write: true, vite:config emptyOutDir: null, vite:config manifest: false, vite:config lib: { formats: [Array], entry: './lib/index.ts' }, 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 }, vite:config optimizeDeps: { force: undefined, esbuildOptions: { preserveSymlinks: undefined } }, vite:config configFile: '/repro-vite-yarn-bug/vite.config.ts', vite:config configFileDependencies: [ '/repro-vite-yarn-bug/vite.config.ts' ], 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: '/repro-vite-yarn-bug', vite:config base: '/', vite:config resolve: { alias: [ [Object], [Object] ] }, vite:config cacheDir: '/repro-vite-yarn-bug/node_modules/.vite', vite:config command: 'build', vite:config mode: 'production', vite:config ssr: undefined, vite:config isWorker: false, vite:config mainConfig: null, vite:config isProduction: true, vite:config plugins: [ vite:config 'vite:build-metadata', vite:config 'alias', vite:config 'vite:modulepreload-polyfill', vite:config 'vite:optimized-deps-build', 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:watch-package-data', vite:config 'vite:data-uri', vite:config 'vite:asset-import-meta-url', 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 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 [Object], [Object], [Object], vite:config [Object], [Object], [Object], vite:config [Object], [Object], [Object], vite:config [Object], [Object], [Object], vite:config [Object], [Object], [Object], vite:config [Object], [Object], [Object], vite:config [Object], [Object], [Object], vite:config [Object], [Object], [Object], vite:config [Object], [Object], [Object] vite:config ], vite:config rollupOptions: {} vite:config }, vite:config appType: 'spa', vite:config experimental: { importGlobRestoreExtension: false, hmrPartialAccept: false } vite:config } +10ms vite v3.0.0-beta.5 building for production... ✓ 1 modules transformed. The "path" argument must be of type string. Received an instance of Buffer error during build: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received an instance of Buffer at new NodeError (node:internal/errors:388:5) at validateString (node:internal/validators:114:11) at Object.isAbsolute (node:path:1157:5) at VirtualFS.mapToBase (/repro-vite-yarn-bug/.pnp.cjs:4308:24) at VirtualFS.rmdirSync (/repro-vite-yarn-bug/.pnp.cjs:4157:39) at PosixFS.rmdirSync (/repro-vite-yarn-bug/.pnp.cjs:4157:24) at URLFS.rmdirSync (/repro-vite-yarn-bug/.pnp.cjs:4157:24) at _rmdirSync (node:internal/fs/rimraf:260:21) at rimrafSync (node:internal/fs/rimraf:193:7) at node:internal/fs/rimraf:253:9
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.
Since rimraf is mentioned in the error this might be an error in its implementation, I’m not sure how vite uses it though
Issue Analytics
- State:
- Created a year ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Plug'n'Play | Yarn - Package Manager
An overview of Plug'n'Play, a powerful and innovative installation strategy for Node.
Read more >Is there's a command for yarn to install a subfolder?
I have a root directory which contains a few subfolders. Each holds a different service. I want to create a script in the...
Read more >Getting rid of node_modules with Yarn Plug'n'Play
It was strange for me, at first, to use NPM for other things than Node modules, but I got used to the idea...
Read more >vite - bytemeta
Vite dev returns 404 HTTP status error when the project name has the '%20' ... Strange error with vite@beta on every other build...
Read more >Strange build error with yarn add - beginner - ReScript Forum
I'm stuck in a very strange error that completely prevents me from building a rescript react application. Why or how this error happens...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for the link! I’ll keep a track of that issue
Yes I did use your repo.
I was not able to reproduce with node 16.15.0. But I was able to reproduce with node 18.3.0. I think this is a bug in yarn or node.