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

failedTask=build stackTrace=TypeError: The "path" argument must be of type string. Received undefined #8870

Open
dingshaohua-com opened this issue Feb 17, 2025 · 10 comments

Comments

@dingshaohua-com
Copy link

 electron-builder  version=26.0.6 os=24.3.0
  • loaded configuration  file=/Users/dsh/files.localized/code/live-student-fe/src/apps/electron/electron-builder.json
  • description is missed in the package.json  appPackageFile=/Users/dsh/files.localized/code/live-student-fe/src/apps/electron/package.json
  • writing effective config  file=/Users/dsh/files.localized/code/live-student-fe/dist/builder-effective-config.yaml
  • executing @electron/rebuild  electronVersion=22.3.27 arch=x64 buildFromSource=false appDir=./
  • installing native dependencies  arch=x64
  • completed installing native dependencies
  • packaging       platform=darwin arch=x64 electron=22.3.27 appOutDir=/Users/dsh/files.localized/code/live-student-fe/dist/mac-universal-x64-temp
  ⨯ The "path" argument must be of type string. Received undefined  failedTask=build stackTrace=TypeError: The "path" argument must be of type string. Received undefined
    at Object.normalize (node:path:1206:5)
    at flatten (/Users/dsh/files.localized/code/live-student-fe/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/app-builder-lib/src/node-module-collector/nodeModulesCollector.ts:64:49)
    at flatten (/Users/dsh/files.localized/code/live-student-fe/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/app-builder-lib/src/node-module-collector/nodeModulesCollector.ts:69:9)
    at flatten (/Users/dsh/files.localized/code/live-student-fe/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/app-builder-lib/src/node-module-collector/nodeModulesCollector.ts:69:9)
    at flatten (/Users/dsh/files.localized/code/live-student-fe/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/app-builder-lib/src/node-module-collector/nodeModulesCollector.ts:69:9)
    at flatten (/Users/dsh/files.localized/code/live-student-fe/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/app-builder-lib/src/node-module-collector/nodeModulesCollector.ts:69:9)
    at flatten (/Users/dsh/files.localized/code/live-student-fe/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/app-builder-lib/src/node-module-collector/nodeModulesCollector.ts:69:9)
    at NpmNodeModulesCollector.convertToDependencyGraph (/Users/dsh/files.localized/code/live-student-fe/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/app-builder-lib/src/node-module-collector/nodeModulesCollector.ts:73:5)
    at NpmNodeModulesCollector.getNodeModules (/Users/dsh/files.localized/code/live-student-fe/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/app-builder-lib/src/node-module-collector/nodeModulesCollector.ts:155:34)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
@beyondkmp
Copy link
Collaborator

Can you provide a reproducible demo? Or share the dependencies and devDependencies of your project?

@mmaietta
Copy link
Collaborator

I saw this during my refactoring and wasn't sure if it was caused by my code tbh, but there should be some safeguards added in #8872 that might resolve this.

@lishid
Copy link

lishid commented Feb 18, 2025

Seeing the same issue with 26.0.6, mac only, with native dependencies as well. The stacktrace seems similar to #8842

@mmaietta
Copy link
Collaborator

@lishid could you share a minimum reproducible repo or at least your package.json so that we can replicate the issue on our side?

Also can you please try 26.0.7? The release includes an additional fix for the node module collector logic.

@lishid
Copy link

lishid commented Feb 18, 2025

Apologies, I meant to say I was using 26.0.7. Our package.json has two internal native dependencies (plus @electron/remote) so it's a bit difficult to share, but I will try and see if I can get a minimal repro setup.

Not sure if this is related, but the internal native dependencies are imported from an upper level directory (../package-name) and are symlinked into node_modules. Previously in 25.x we've ran into the issue where electron-builder wasn't happy with out-of-directory dependencies (the "must be under" error) which has been resolved since upgrading to v26.

@mmaietta
Copy link
Collaborator

For native dependencies, deps I like to use to test with is node-mac-permissions and sqlite3, but it sounds like your project may be too unique for that to suffice.

For a minimum repro, I use electron-quick-start project as a template to get easily/quickly set up. Hope that helps!

@lishid
Copy link

lishid commented Feb 18, 2025

Ok I've found the cause of my issue after tracing through the code execution. It seems that we had @electron/remote specified in the package.json inside our app directory (using the two package.json structure) but it was not npm i'ed. I guess in previous versions of electron-builder this may have worked because we also have a copy of it installed in the upper level.

I noted that in nodeModulesCollector.ts > convertToDependencyGraph(tree) > flatten we are seeing the following dependency object, where the lack of a path property triggers this error.

"@electron/remote": {
  required: '2.1.2',
  missing: true,
  problems: [ 'missing: @electron/[email protected], required by [email protected]' ]
}

@beyondkmp
Copy link
Collaborator

@lishid In your internal native dependencies, are their dependencies installed via yarn or npm install firstly? If not, it could potentially lead to this error. This is because the required dependencies cannot be found within your internal native dependencies.

In previous implementations, if a dependency couldn't be found, it would simply be ignored without throwing an error, and the project would directly use a dependency with the same name from the current project, which might result in version

@lishid
Copy link

lishid commented Feb 19, 2025

Our internal dependences are simply checked into the repo, and they are referred to using npm dependency as "package": "../package". It seems that in this case npm automatically made a symlink to the folder. However the error here seems to be the missing @electron/remote which behaved as you described - silently ignored and automatically using the current project's copy, but since the upgrade it had errored out because it was somehow missing in the app's node modules.

I've performed an npm install in the app directory which installed the missing dep and the error is gone, all is good for now.

I am reporting back because this error is lacking in details and that makes debugging difficult. I think a reasonable improvement could be to check the value here and terminate with an appropriate error message, rather than letting path.normalize error out because undefined was passed in.

@mmaietta
Copy link
Collaborator

I'm adding additional logging in #8872 as part of the refactor. It also adds some safeguards in but I'll double-check the setup to see if I can replicate your configuration.
I'm also adding additional error/debug logging, such as when the dependency is missing a path

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants