question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Webpack template does not work with native modules on Windows

See original GitHub issue

Pre-flight checklist

  • I have read the contribution documentation for this project.
  • I agree to follow the code of conduct that this project uses.
  • I have searched the issue tracker for a bug that matches the one I want to file, without success.

Electron Forge version

6.0.0-beta.64

Electron version

v19.0.7

Operating system

Windows 10 (19044)

Last known working Electron Forge version

No response

Expected behavior

Webpack template should work with native modules on Windows

Actual behavior

Webpack template fails with native modules because it uses Linux paths on Windows

Steps to reproduce

  1. As per steps on the documentation, run: npx create-electron-app my-new-app --template=webpack
  2. Add a native module npmjs package, like this one: yarn add @nut-tree/nut-js
  3. Package application using yarn package.

Received error:

WARNING in ./src/main.js
Invalid dependencies have been reported by plugins or loaders for this module. All reported dependencies need to be absolute paths.
Invalid dependencies may lead to broken watching and caching.
As best effort we try to convert all invalid values to absolute paths and converting globs into context dependencies, but this is deprecated behavior.
Loaders: Pass absolute paths to this.addDependency (existing files), this.addMissingDependency (not existing files), and this.addContextDependency (directories).
Plugins: Pass absolute paths to fileDependencies (existing files), missingDependencies (not existing files), and contextDependencies (directories).
Globs: They are not supported. Pass absolute path to the directory as context dependencies.
The following invalid values have been reported:
 * "G:/t2/new-app/node_modules/@babel/runtime/LICENSE"
 * "G:/t2/new-app/node_modules/@babel/runtime/helpers/AsyncGenerator.js"
 * "G:/t2/new-app/node_modules/@babel/runtime/helpers/AwaitValue.js"
 * and more ...

Additional information

Vercel webpack asset relocator loader v1.7.1 has a fix for Windows path handling. See commit: https://github.com/vercel/webpack-asset-relocator-loader/commit/38f839f36b6e80c925194cb8442b6b0f0f3f2e31

But the webpack template for electron is pinned to version 1.7.0 (see docs), therefore this fix is missing from there. The docs linked above say that:

Warning: Electron Forge needs to monkeypatch the asset relocator loader in order for it to work with Electron properly, so the version has been pinned to ensure compatibility. If you upgrade that version, you do so at your own risk.

Now I upgraded the package to 1.7.2 and still got the same error on packaging. I wonder if the monkeypatch is interfering with vercel’s patch.

Would appreciate any quick workarounds to solve this, while a proper fix is implemented.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
VerteDindecommented, Jul 21, 2022

@GaurangTandon No worries at all, really appreciate both the report and the fast response! Let us know if you have any issues in the future 🙂

1reaction
GaurangTandoncommented, Jul 21, 2022

Hi @VerteDinde , I am very surprised as now I am also unable to reproduce the issue. Only Electron seems to have updated to v19.0.8 in the meantime, but the update seems irrelevant to this issue.

I apologize I don’t have any more information. Feel free to close this ticket if you wish to.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Webpack template does not work with native modules on ...
I have searched the issue tracker for a bug that matches the one I want to file, without success. Electron Forge version. 6.0.0-beta.64 ......
Read more >
cannot use native node module in electron-forge app
I am trying to use pkcs11js in an electron app created with electron-forge using webpack template. But I ...
Read more >
How I solved and debugged my Webpack issue through trial ...
When webpack bundles your source code, it can become difficult to track down errors and warnings to their original location.
Read more >
Externals - webpack
The externals configuration option provides a way of excluding dependencies from the output bundles. Instead, the created bundle relies on that dependency ...
Read more >
Webpack | WebStorm Documentation - JetBrains
Make sure the JavaScript and TypeScript and Webpack required plugins are enabled on the Settings/Preferences | Plugins page, tab Installed, see ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found