-
-
Notifications
You must be signed in to change notification settings - Fork 22
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
Module present in the snapshot cannot be found #125
Comments
Try to check https://github.com/yao-pkg/pkg#troubleshooting and then if nothing works go to last advanced section to create a debug binary and lunch it to see if you can gain some more informations |
As per the troubleshooting section, the first 2 seem to be relevant.
For the debug section: I verified that the snapshot contains the files that the code is trying to import, at the same path which is mentioned in the error message - thus making it all the more interesting. UPDATE:
|
@swanux please try to package using |
@robertsLando See attachment: logs.txt (I ran the linux binary, but they produce the same error) |
@swanux The issue is in function registerESMLoader() {
const {
port1,
port2
} = new MessageChannel();
// register will wait until the loader is initialized.
require('node:module').register(_url.default.pathToFileURL(require.resolve('../transform/esmLoader')), {
parentURL: _url.default.pathToFileURL(__filename),
data: {
port: port2
},
transferList: [port2]
});
loaderChannel = createPortTransport(port1);
exports.esmLoaderRegistered = esmLoaderRegistered = true;
} |
@robertsLando yep, I also looked at this part - but I dismissed it as the cause of the issue, because it works with the original vercel pkg. First I thought it's because of the newer node20 I used for build (because there's an if in the code that executes differently when running on node>=20) but I got the same error with node18 as well. So why does it work with the old pkg, and not the new one, even using the same node versions? |
Hummm I have no clue maybe in the old pkg version you were using node 16 or a different playwright version? I have a feel this may work with node 16 target as starting from node 18 there have been some changes to esm |
No, that's the weird part. I still use the old pkg with node18 and the same playwright version in production (as I am just experimenting with migrating away from the deprecated version). And it works without an issue. Maybe one of the changes / patches is somehow affecting it? |
@swanux starting from I don't remember which minor version nodejs 18 started giving the same problem related to esm modules so I think the reason is that, could you try with 16? If it works with 16 the reason is this |
@robertsLando I tried it now with node16 - same results... |
No clue so I'm sorry, I'm out of ideas now... My feel is that the way playwright uses to load that module is strange and it's not well digested by pkg for some reason |
What version of pkg are you using?
6.1.0
What version of Node.js are you using?
20
What operating system are you using?
Fedora 41
What CPU architecture are you using?
x86_64
What Node versions, OSs and CPU architectures are you building for?
node20-linux-x64, node20-windows-x64
Describe the Bug
Calling playwright through the binary (node_modules/.bin), the same way as it used to work with the original vercel/pkg, it throws the following error:
While the following code (from within the compiled program):
console.log(fs.readdirSync("/snapshot/autotest/node_modules/playwright/lib/transform"));
Gives the following result:
Indicating that the required file is clearly present in the snapshot.
Expected Behavior
The module import should be successful.
To Reproduce
Have the following config for pkg in your package.json:
Try to call playwright test from within the compiled code, according to this:
The text was updated successfully, but these errors were encountered: