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

Unable to run the app on Windows with steamworks.js #3193

Open
3 tasks done
vsobotka opened this issue Mar 23, 2023 · 3 comments
Open
3 tasks done

Unable to run the app on Windows with steamworks.js #3193

vsobotka opened this issue Mar 23, 2023 · 3 comments

Comments

@vsobotka
Copy link

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.5

Electron version

23.0.0

Operating system

Windows 11 Home, 22H2

Last known working Electron Forge version

No response

Expected behavior

The app opens.

Actual behavior

I get the following error when trying to run the app either from the exe generated by make or when started with start command.

pp threw an error during load
Error: The specified module could not be found.
\\?\C:\Users\vsobotka\workspace\landia\desktop_app\.webpack\main\native_modules\dist\win64\steamworksjs.win32-x64-msvc.node
    at process.func [as dlopen] (node:electron/js2c/asar_bundle:2:1822)
    at Module._extensions..node (node:internal/modules/cjs/loader:1259:18)
    at Object.func [as .node] (node:electron/js2c/asar_bundle:2:1822)
    at Module.load (node:internal/modules/cjs/loader:1044:32)
    at Module._load (node:internal/modules/cjs/loader:885:12)
    at f._load (node:electron/js2c/asar_bundle:2:13330)
    at Module.require (node:internal/modules/cjs/loader:1068:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at ./node_modules/steamworks.js/dist/win64/steamworksjs.win32-x64-msvc.node (C:\Users\vsobotka\workspace\landia\desktop_app\.webpack\main\index.js:933:18)
    at __webpack_require__ (C:\Users\vsobotka\workspace\landia\desktop_app\.webpack\main\index.js:1200:42)

I verified all the files mentioned above, and they are present on the location they are expected.

Steps to reproduce

Simple electron app with steamworks.js ran on Windows 11 in Parallels Desktop should reproduce the issue. Not sure if it's important, but I use M2 Apple Silicon chip.

Additional information

Until we added steamworks.js, the app was working.

Not sure if it can be related, but I am running the project on M2 MacBook Pro, where I have Parallels Desktop and Windows 11 Home installed. So it is 64bit architecture running on ARM hardware. It is working for a colleague with Windows 11 machine just fine.

@arepp23
Copy link

arepp23 commented Aug 16, 2023

Not able to recreate this issue but one of my users is reporting the same.

@LZQCN
Copy link

LZQCN commented Nov 14, 2023

The reason for this error may be the .node file cannot find the .dll file in the same directory.

I used esbuild to bundle dependencies. Initially, the build parameters were as follows:

{
  entryPoints: ["./src/main.ts"],
  bundle: true,
  platform: "node",
  outfile: "./dist/main.js",
  target: "es2017",
  format: "cjs",
  external: ["electron", "steamworks.js"],
  sourcemap: true,
}

These build parameters externalize steamworks.js, meaning it will not be bundled. Running not result in any errors.

Then, I changed the parameters to:

{
  entryPoints: ["./src/main.ts"],
  bundle: true,
  platform: "node",
  outfile: "./dist/main.js",
  target: "es2017",
  format: "cjs",
  external: ["electron"],
  sourcemap: true,
  loader: {
    ".node": "copy",
  }
}

These parameters bundle steamworks.js and correctly copy the .node files.

However, I encountered an error during runtime:

Error: The specified module could not be found.

I realized that the error was due to the fact that these files were not copied. esbuild cannot bundle these files. The following files need to be manually copied to the dist directory:

node_modules\steamworks.js\dist\linux64\libsteam_api.so
node_modules\steamworks.js\dist\osx\libsteam_api.dylib
node_modules\steamworks.js\dist\win64\steam_api64.dll
node_modules\steamworks.js\dist\win64\steam_api64.lib

In addition, if you manually add dll, you also need to set the packagerConfig.asar option to false in forge.config.js. Otherwise, after executing electron-forge package, the packaged product will still prompt:

Error: The specified module could not be found.

The content of my forge.config.js configuration file used for my project(pnpm + electron-forge + esbuild) is as follows:

module.exports = {
  packagerConfig: {
    asar: false,
    prune: false,
    ignore: [/node_modules/],
  },
  rebuildConfig: {},
  makers: [
    {
      name: "@electron-forge/maker-squirrel",
      config: {},
    },
    {
      name: "@electron-forge/maker-zip",
      platforms: ["darwin"],
    },
    {
      name: "@electron-forge/maker-deb",
      config: {},
    },
    {
      name: "@electron-forge/maker-rpm",
      config: {},
    },
  ],
  plugins: [],
};

@Firesnake23
Copy link

@LZQCN Thank you your solution worked.
Altough i only needed to copy the files steamapi64.dll and steamapi64.lib
from the win64 to make it work.

That solution only works for windows, in most other cases you should copy the entire dist directory
In my forge.config.jsi use the postPackage hook to copy these around.

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