ceifa / steamworks.js

A steamworks implementation for nw.js/electron games
MIT License
395 stars 64 forks source link

Can't find binaries on windows + electron-forge #75

Open vsobotka opened 1 year ago

vsobotka commented 1 year ago

I am trying to work on a steam integration for our game on a M2 Mac, but due to the overlay not working (#50) I decided to use the Parallels Desktop instead. But on Windows in Parallels I am getting this error:

App 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)

We are using electron forge to wrap our app, and this is the error thrown by either electron-forge start or by trying to execute the exe from electron-forge make. Is it not supposed to work, or am I missing something?

ceifa commented 1 year ago

Never used electron-forge, but as the error says, it is trying to get a file that don't exists. I think to solve you just have to move the files on your build script.

vsobotka commented 1 year ago

The error is not very readable for me, not sure what it is trying to do under the hood. But before we added the steamworks.js to the project it was working. I also verified and all the files mentioned in the stack trace are on the expected locations.

mcolotto commented 1 year ago

Hello, I am having the same issue on my released game, which does not use electron-forge - instead it uses electron-webpack and electron-builder. The vast majority of players don't seem to be affected by this bug, and I myself cannot reproduce, but I am getting a few reports. In the affected cases, the file is physically present in the location, and not packed in the .asar for the app.

I don't think this info is very helpful, but wanted to add a datapoint since I saw this while trying to debug the issue.

mcolotto commented 1 year ago

Hey, I was able to debug what was going on. It turns out that if you are missing the file VCRUNTIME140.dll the native module will fail to load and give this cryptic error message. See: https://stackoverflow.com/questions/41253450/error-the-specified-module-could-not-be-found

The solution was to include the latest Visual C++ Redist on the game configuration in the Steamworks admin (installation -> redistributables) so that it automatically installs when the game installs.

If you are facing this error, installing the Visual C++ redistributable should solve the problem. Otherwise it is possible this can also be solved if the file is included with steamworks.js together with the library, but given we're publishing on Steam anyway this seems like a much cleaner way to do it, just needs to be documented somewhere.

ceifa commented 1 year ago

Hey, I was able to debug what was going on. It turns out that if you are missing the file VCRUNTIME140.dll the native module will fail to load and give this cryptic error message.

Where did you see that this file was missing?

If you are facing this error, installing the Visual C++ redistributable should solve the problem. Otherwise it is possible this can also be solved if the file is included with steamworks.js together with the library, but given we're publishing on Steam anyway this seems like a much cleaner way to do it, just needs to be documented somewhere.

Related https://github.com/ceifa/steamworks.js/issues/38

mcolotto commented 1 year ago

Where did you see that this file was missing?

I didn't actually see that the file was missing. This was a combination of asking someone with the problem to help me debug, and using Dependency Walker (http://www.dependencywalker.com/) to figure out what were the DLLs that were needed by the .node file, Since I hadn't set up my game to automatically install the redist, I suspected that may have been the issue - and changing the setting and asking the player who was helping me debug to reinstall the game actually worked to fix this problem, so I'm fairly confident that was the cause.

Related #38

I'm not sure why this dependency is needed either, but until that issue is figured out it might be a good idea to add a note to the installation instructions on the README.md that it's needed.

vsobotka commented 1 year ago

@mcolotto Awesome! Installing https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170 seems to fix the issue for me. I still have some issues with my setup, but the game starts without an error.

IlTimido commented 1 year ago

I can't make it work. I'm on windows 10. I installed also the VCRUNTIME140.dll as suggested but when it starts it gives me an error like the one above. If I launch it with "electron-forge start" all works perfectly but when I pack and I go to the out win32etc etc directory and launch the exe from there, it hangs. If I remove references to steamworks.js, all works fine. The erros is that it seems that it can't find steamworksjs.win32-x64-msvc.node at the specified path, but the file is there. However how it is possible that I can't find any steam***.dll in the directories? It is normal? I'm doing this test with the test steamapp id 480 but as I have said with "electron-forge start" all works fine. Any help?

IlTimido commented 1 year ago

Hi guys, I think I have solved the problem. I can't tell if it's related to VCRUNTIME140.dll or not, all I can say is that installing the redist people wrote about didn't solved my issue.

I solved JUST COPYING THE FILES "steam_api64.dll" and "steam_api64.lib" in the same directory where "steamworksjs.win32-x64-msvc.node" stands that is "[PROJECTNAME]\resources\app.asar.unpacked\node_modules\steamworks.js\dist\win64" I copied them from the "node_modules\steamworks.js\dist\win64"

I used this program to check what was the dependencies that was missing "https://github.com/lucasg/Dependencies" and it told me that it was "steam_api64.dll"

flyinghail commented 12 months ago

Hi guys, I think I have solved the problem. I can't tell if it's related to VCRUNTIME140.dll or not, all I can say is that installing the redist people wrote about didn't solved my issue.

I solved JUST COPYING THE FILES "steam_api64.dll" and "steam_api64.lib" in the same directory where "steamworksjs.win32-x64-msvc.node" stands that is "[PROJECTNAME]\resources\app.asar.unpacked\node_modules\steamworks.js\dist\win64" I copied them from the "node_modules\steamworks.js\dist\win64"

I used this program to check what was the dependencies that was missing "lucasg/Dependencies" and it told me that it was "steam_api64.dll"

It does solve the problem. The problem now is how to make "steam_api64.dll" and "steam_api64.lib" copy automatically when electron forge make.

IlTimido commented 12 months ago

Hi guys, I think I have solved the problem. I can't tell if it's related to VCRUNTIME140.dll or not, all I can say is that installing the redist people wrote about didn't solved my issue. I solved JUST COPYING THE FILES "steam_api64.dll" and "steam_api64.lib" in the same directory where "steamworksjs.win32-x64-msvc.node" stands that is "[PROJECTNAME]\resources\app.asar.unpacked\node_modules\steamworks.js\dist\win64" I copied them from the "node_modules\steamworks.js\dist\win64" I used this program to check what was the dependencies that was missing "lucasg/Dependencies" and it told me that it was "steam_api64.dll"

It does solve the problem. The problem now is how to make "steam_api64.dll" and "steam_api64.lib" copy automatically when electron forge make.

You mean to make the installer with these files inside right? I haven't foud a solution, luckily on Steam this is not needed because I can upload a zip that contains the build of the project and all works fine.

flyinghail commented 12 months ago

You mean to make the installer with these files inside right? I haven't foud a solution, luckily on Steam this is not needed because I can upload a zip that contains the build of the project and all works fine.

Does it work for you to package steamworks.js with electron forge?

I packaged the program with the electron-forge package and ran it with steam. The whole window is black, I don't know how to fix it.

I try to run init() in the main process and get an error: Error: failed to init the steamworks API.

I try to run init() in the renderer process, the whole window is black. Then, I try to output to the log file before init() and nothing is logged. Tried alert() before init() and nothing happens.

IlTimido commented 12 months ago

You mean to make the installer with these files inside right? I haven't foud a solution, luckily on Steam this is not needed because I can upload a zip that contains the build of the project and all works fine.

Does it work for you to package steamworks.js with electron forge?

I packaged the program with the electron-forge package and ran it with steam. The whole window is black, I don't know how to fix it.

I try to run init() in the main process and get an error: Error: failed to init the steamworks API.

I try to run init() in the renderer process, the whole window is black. Then, I try to output to the log file before init() and nothing is logged. Tried alert() before init() and nothing happens.

Have you included in the package the steam_appid.txt with the id of your app (or 480 that is the steam app for test)? I've found this precious tutorial on how to use steamworks.js https://liana.one/integrate-electron-steam-api-steamworks

flyinghail commented 12 months ago

Have you included in the package the steam_appid.txt with the id of your app (or 480 that is the steam app for test)? I've found this precious tutorial on how to use steamworks.js liana.one/integrate-electron-steam-api-steamworks

Thanks. From the article, it should be possible to run init() in the main process. Looks like I can try to fix that first.

Inateno commented 8 months ago

Fresh project here as I was getting issues with electron-builder I tried electorn-forge. The asar option "true" trigger this error.

@ceifa what do you use as you said "do not use electron-forge" please?

Aside the asar issue, electron-forge works better the electron-builder for me (less issues arounds steam-overlay mostly).

ceifa commented 8 months ago

@ceifa what do you use as you said "do not use electron-forge" please?

I was just saying that I never used before. I use electron builder, but for no particular reason.

Inateno commented 8 months ago

I was just saying that I never used before. I use electron builder, but for no particular reason.

Ok no problem I was wondering if you had any particular issue. I was using electron-builder, but the team wanted to try electron-packager directly which was not "good enough" for me, and I was trying electron-forge when I saw you comment lol (btw so far so good, I think I prefer it over electron-builder).

gen256 commented 6 months ago

my solution

forge.config.js

module.exports = {
   packagerConfig: {
     asar: {
       unpackDir: "node_modules/steamworks.js/dist/**/*"
     }
   },
   ...
AuWiMo commented 6 months ago

my solution

forge.config.js

module.exports = {
   packagerConfig: {
     asar: {
       unpackDir: "node_modules/steamworks.js/dist/**/*"
     }
   },
   ...

This solution worked for me and is incredibly simple. I will make a pull request to add this to the readme as it seems lots of users are having this issue.

officialrobert commented 3 months ago
module.exports = {
   packagerConfig: {
     asar: {
       unpackDir: "node_modules/steamworks.js/dist/**/*"
     }
   },

this doesn't work with webpack + typescript template, any tips?

AlexStormwood commented 3 months ago

@officialrobert This works for me in my Electron Forge Webpack + ReactJS project:

asar: {
      unpack: "*.{node,dll,so}"
    },
AlexStormwood commented 3 months ago

Just adding to note, too, that this is almost definitely a developer environment issue now. I have a project that has been building & running and publishing to Steam with no problem for the last couple of weeks. I formatted my computer yesterday, reinstalled what I thought was everything, but must've missed something: the exact same repo that was building 2 days ago was no longer working, giving the exact same error that the OP is showing.

My project builds perfectly fine in GitHub Actions Ubuntu and Windows runners, so I know it was definitely something in the dev computer.

I installed Visual Studio Community and the Visual Studio Community Build Tools with all the packages/features that seemed relevant to app development, as well as the Steamworks SDK Redist in Steam, restarted my computer, and then things started working again.

officialrobert commented 3 months ago

@officialrobert This works for me in my Electron Forge Webpack + ReactJS project:

asar: {
      unpack: "*.{node,dll,so}"
    },

Hey @AlexStormwood Thank you so much!