-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Open
Open
Copy link
Labels
Description
Describe the bug
When have a vite 7 repository, and the dependabot upgrade is failing, after investigating we were getting the following error
Stack trace:
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of URL. Received undefined
at fileURLToPath (node:internal/url:1606:11)
The problem is coming from inside the ps-list we are using;
Checking the compile code with vite 8.0.1 we have
var __dirname$1 = node_path.default.dirname((0, node_url.fileURLToPath)({}.url));Looking at the corresponding source code we have
const __dirname = path.dirname(fileURLToPath(import.meta.url));When adding platform: "node" in the rollupOptions the compile code change to
var __dirname$1 = node_path.default.dirname((0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href));However, according to the documentation, this should not be necessary as we use the format cjs, and in the documentation it is written
Default
- 'node' if the format is 'cjs'
- 'browser' for other formats1
Reproduction
https://github.com/axel7083/vite-cjs-node-reproducer
Steps to reproduce
- Checkout https://github.com/axel7083/vite-cjs-node-reproducer
- Run
npm install - Run
npm run demo - Assert
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of URL. Received undefined
System Info
System:
OS: Windows 11 10.0.22000
CPU: (16) x64 AMD Ryzen 7 5800XT 8-Core Processor
Memory: 9.06 GB / 30.94 GB
Binaries:
Node: 24.11.1 - C:\Program Files\nodejs\node.EXE
npm: 11.6.2 - C:\Program Files\nodejs\npm.CMD
pnpm: 10.28.0 - C:\Program Files\nodejs\pnpm.CMD
Browsers:
Edge: Spartan (44.22000.120.0), Chromium (143.0.3650.139)
Internet Explorer: 11.0.22000.120
npmPackages:
vite: ^8.0.1 => 8.0.1Used Package Manager
pnpm
Logs
No response
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.
Footnotes
Reactions are currently unavailable