Preflight Checklist
Electron Version
42.2.0
What operating system(s) are you using?
macOS
Operating System Version
macOS Ventura 13.5 (arm64), Windows 11 25H2 (x64)
What arch are you using?
arm64 (including Apple Silicon)
Last Known Working Electron version
No response
Does the issue also appear in Chromium / Google Chrome?
No
Expected Behavior
fs.glob or fs.globSync with options.withFileTypes expect to return fs.Dirent[] under asar packaged or not. And the fs.Dirent should include a parentPath property.
// dist/index.js
import fs from 'node:fs'
import path from 'node:path'
const direntList = fs.globSync('*.js', { cwd: import.meta.dirname, withFileTypes: true })
/*
[
Dirent {
name: 'index.js',
parentPath: '/path/to/project/dist',
Symbol(type): 1
}
]
*/
Actual Behavior
Dirent.parentPath property is existing under dev runtime npx electron . or build asar: false, but it's missing under asar packaged.
// under asar packaged app
// dist/index.js
import fs from 'node:fs'
import path from 'node:path'
import { dialog } from 'electron'
const direntList = fs.globSync('*.js', { cwd: import.meta.dirname, withFileTypes: true })
// Use showErrorBox to print value after build app.
dialog.showErrorBox('', JSON.stringify(direntList, null, 2))
/*
[
{
"name": "index.js"
// parentPath is missing
}
]
*/
Dirent.parentPath is a relatively new property. It's marked stable in node.js v24.0.0 and v22.17.0. Maybe hasn't been implemented yet in electron asar mode.
https://nodejs.org/api/fs.html#direntparentpath
Testcase Gist URL
No response
Additional Information
The following steps can be used to reproduce the result. Using node.js v24.15.0 same with electron's node.js version.
- Create a new npm project directory and enter it
$ mkdir electron-test
$ cd electron-test
$ npm init --y
- Install dependencies
$ npm install -D electron@42.2.0 electron-builder@26.8.1
- Edit electron-builder config in package.json
- Add
dist/index.js
// dist/index.js
import fs from 'node:fs'
import path from 'node:path'
import { app, dialog } from 'electron'
const direntList = fs.globSync('*.js', { cwd: import.meta.dirname, withFileTypes: true })
// print value
console.log(direntList)
dialog.showErrorBox('', JSON.stringify(direntList, null, 2))
app.exit()
- Run
npx electron . the Dirent.parentPath exists
- Run
npx electron-builder to build app with asar
- Click to launch the packaged app, we can see the
Dirent.parentPath is missing in the dialog
Preflight Checklist
Electron Version
42.2.0
What operating system(s) are you using?
macOS
Operating System Version
macOS Ventura 13.5 (arm64), Windows 11 25H2 (x64)
What arch are you using?
arm64 (including Apple Silicon)
Last Known Working Electron version
No response
Does the issue also appear in Chromium / Google Chrome?
No
Expected Behavior
fs.globorfs.globSyncwithoptions.withFileTypesexpect to returnfs.Dirent[]under asar packaged or not. And thefs.Direntshould include aparentPathproperty.Actual Behavior
Dirent.parentPathproperty is existing under dev runtimenpx electron .or buildasar: false, but it's missing under asar packaged.Dirent.parentPath is a relatively new property. It's marked stable in node.js
v24.0.0andv22.17.0. Maybe hasn't been implemented yet in electron asar mode.https://nodejs.org/api/fs.html#direntparentpath
Testcase Gist URL
No response
Additional Information
The following steps can be used to reproduce the result. Using node.js
v24.15.0same with electron's node.js version.$ mkdir electron-test $ cd electron-test $ npm init --ydist/index.jsnpx electron .the Dirent.parentPath existsnpx electron-builderto build app with asarDirent.parentPathis missing in the dialog