pkg
pkg copied to clipboard
package with .node not working
when i pkg my project that use robotjs and opencv4nodejs this message comes out and exe not throw error. any one know how to solve this?
when pkg -d `
[debug] prebuild-install failed[C:\Users\MinkyuKim\Desktop\project\template_match_test\node_modules\robotjs\build\Release\robotjs.node]: spawnSync C:\Users\MinkyuKim\Desktop\project\template_match_test\node_modules\pkg\node_modules.bin\prebuild-install ENOENT [debug] prebuild-install failed[C:\Users\MinkyuKim\Desktop\project\template_match_test\node_modules\opencv4nodejs-prebuilt\build\Release\opencv4nodejs.node]: spawnSync C:\Users\MinkyuKim\Desktop\project\template_match_test\node_modules\pkg\node_modules.bin\prebuild-install ENOENT `
when execute exe file
`
Error: The specified module could not be found.
C:\Users\MINKYU~1\AppData\Local\Temp\pkg\93dbf0b51154096661d2ec65984eaa3f324401115e046c86582f863f538cb404\opencv4nodejs-prebuilt\build\Release\opencv4nodejs.node
at process.dlopen (pkg/prelude/bootstrap.js:2114:28)
at Object.Module._extensions..node (internal/modules/cjs/loader.js:1144:18)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Module.require (internal/modules/cjs/loader.js:974:19)
at Module.require (pkg/prelude/bootstrap.js:1719:31)
at require (internal/modules/cjs/helpers.js:93:18)
at Object.
Try to add that .node file to assets
Is your problem solved yet ? Because I encounter a same problem
I tested with assets with same issue. Also tested require.js file has similar issue. Pkg executable has the require statement as text but it isn't resolved at runtime. Reverted to pkg 5.5.1 and the issue does not exist.
Perhaps the platform specific bindings aren't getting included the the packaged binary. One workaround I came across was simply putting them in the root directory of the executable. Does that solve the issue?
From: Deathmetal007 @.> Sent: Thursday, January 20, 2022 3:04 AM To: vercel/pkg @.> Cc: Subscribed @.***> Subject: Re: [vercel/pkg] package with .node not working (Issue #1477)
I tested with assets with same issue. Also tested require.js file has similar issue. Pkg executable has the require statement as text but it isn't resolved at runtime. Reverted to pkg 5.5.1 and the issue does not exist.
— Reply to this email directly, view it on GitHubhttps://github.com/vercel/pkg/issues/1477#issuecomment-1016877686, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AHGCLB3YNPE5EQYMSLKSTKLUW4THHANCNFSM5LZ3HBZA. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you are subscribed to this thread.Message ID: @.***>
The workaround is valid at any location if the require to the node addon is not nested, i.e. using a require to an export does not work. I use a direct path for zeromq for example require('node_modules/addons/zmq.node') in the zeromq binding.js instead of require('addons/zmq.node')
This has already been fixed at https://github.com/vercel/pkg/blob/edfcc7b139d667d6be0e46f4101e917ca9c154bd/prelude/bootstrap.js#L2197 but somehow isn't included in 5.5.2. The workaround is to have a node_modules in the path, otherwise nothing is copied.
see this https://github.com/vercel/pkg/discussions/1623#discussioncomment-2729625 @FahrulID @cheul123a
This issue is stale because it has been open 90 days with no activity. Remove the stale label or comment or this will be closed in 5 days. To ignore this issue entirely you can add the no-stale label
Has it been resolved?
This is not really an issue, more like a user configuration error. I'm using pkg with really complex projects and I never had modules issues when I correctly add them to assets as described in docs
@robertsLando Thanks for your suggestion. require(some_variable) which are not working inside node_modules. I've configured pkg.scripts at package.json. Whatever, I solved this issue myself.
This issue is stale because it has been open 90 days with no activity. Remove the stale label or comment or this will be closed in 5 days. To ignore this issue entirely you can add the no-stale label
This issue is now closed due to inactivity, you can of course reopen or reference this issue if you see fit.