dustmop / rasterjs

retro graphics framework
10 stars 0 forks source link

Error while getting the cppmodule #1

Closed SimoneAncona closed 1 year ago

SimoneAncona commented 1 year ago

After building and running the project i recive the following error:

Error: The specified module could not be found..
\\?\C:\Users\simon\Documents\...\node_modules\raster\build\Release\native.node
    at Module._extensions..node (node:internal/modules/cjs/loader:1243:18)
    at Module.load (node:internal/modules/cjs/loader:1037:32)
    at Module._load (node:internal/modules/cjs/loader:878:12)
    at Module.require (node:internal/modules/cjs/loader:1061:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.<anonymous> (C:\Users\simon\Documents\...\node_modules\raster\src\node_env.js:1:19)
    at Module._compile (node:internal/modules/cjs/loader:1159:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
    at Module.load (node:internal/modules/cjs/loader:1037:32)
    at Module._load (node:internal/modules/cjs/loader:878:12) {
  code: 'ERR_DLOPEN_FAILED'
}

I noticed that, in the file node_env.js, in the first line there is a require to a file that does not exists. ../build/Release/native is the relative path used to import a C++ module

dustmop commented 1 year ago

@SimoneAncona thanks for trying this out. SDL support is somewhat of a work-in-progress, so I appreciate the feedback. Could you let me know the steps you did before this, that is, the specific commands you executed to build and run the code? Also, this looks like Windows, could you let me know what shell / terminal program you're running these commands in?

SimoneAncona commented 1 year ago

@SimoneAncona thanks for trying this out. SDL support is somewhat of a work-in-progress, so I appreciate the feedback. Could you let me know the steps you did before this, that is, the specific commands you executed to build and run the code? Also, this looks like Windows, could you let me know what shell / terminal program you're running these commands in?

First of all i downloaded the latest SDL2 (2.26.5) library from GitHub and unzipped the tar.gz file into C:\ Then I installed raster and passed the locate_sdl.js check To build I used npm run build that build my TypeScript project But when i run the project it crashes. I use PowerShell as shell but I also tried with WSL Ubuntu bash

dustmop commented 1 year ago

Thank you, this is very helpful info. I'm able to reproduce this problem and will work on a fix, I hope to have one ready soon. Also it looks like SDL changed their download page and raster.js needs to update its docs.

dustmop commented 1 year ago

Could you please try out a workaround? From the SDL releases page download SDL2-2.26.5-win32-x64.zip (the first link), unzip it and place the file SDL2.dll in the same directory that you're running npm / node commands in.

This step shouldn't be necessary in the long-term, I would just like to have you try it out and see if it fixes this immediate error that you're reporting.

SimoneAncona commented 1 year ago

Could you please try out a workaround? From the SDL releases page download SDL2-2.26.5-win32-x64.zip (the first link), unzip it and place the file SDL2.dll in the same directory that you're running npm / node commands in.

This step shouldn't be necessary in the long-term, I would just like to have you try it out and see if it fixes this immediate error that you're reporting.

I moved the SDL2.dll and it works

dustmop commented 1 year ago

Glad to hear it! I think I know the proper fix, I'll get it in soon and then close this issue.

dustmop commented 1 year ago

I published a new version of raster.js, it's version 0.7.9. It fixes this issue by using a postinstall hook to copy the SDL2.dll into the proper location in node_modules after the native addon gets built. If you uninstall raster and delete the SDL2.dll file you copied into your project folder, then installing this new version should work. Just make sure that the zip you've dowloaded from SDL's releases is the "devel" version. The full installation instructions have been updated: https://github.com/dustmop/rasterjs#nodejs