-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Loading native Node module fails with "stream did not contain valid UTF-8" #17246
Comments
For comparison, this script 'use strict'
const md = require('node-mdaemon-api');
const moduleInfo = md.getModuleInfo();
console.dir(moduleInfo); works correctly under Node v18.13.0. |
Node.js refuses to load this file:
From what I gather native extensions must always be |
Thank you @bartlomieju for taking the time to verify this behaviour. Unfortunately I forgot to point out that the native node-mdaemon-api module (I am the author) only exists for Windows x64, not for Mac. I created a repository with these scripts by specifying exactly the requirements in the |
No worries, I figured that out and created a simple project that does the same thing but can be compiled on ARM.
Sure, I'll try to look into fixing this problem next week - we should at least have a nice error saying what's wrong here. Side note: it's surprising that there's still no way to import Node API modules via ESM. |
With
the error message has changed
|
As @loynoir suggested in #19130 , I tried to directly
|
I did not suggest that. I suggest > await import('npm:node-mdaemon-api@23.0.0-alpha.21/cjs-wrapper-to-node-mdaemon-api-node.cjs'); |
@loynoir Sorry, I didn't realise you were suggesting writing a CJS module that in turn would take care of loading the native module. I wrote a simple one 'use strict'
const md = require('./node-mdaemon-api.node');
module.exports = md; and running the minimal
const md = await import ('npm:node-mdaemon-api@23.0.0-alpha.21/index.cjs'); now outputs
where I see that Deno finds the script correctly (it is in the same directory as |
Are you using |
@loynoir yes, I am (via node-addon-api 6.1.0). |
With current
you get a slightly different message when running
However, when running the minimal script const md = await import ('npm:node-mdaemon-api@23.0.0-alpha.21/index.cjs'); but having placed the
|
With current
with same const md = await import ('npm:node-mdaemon-api@23.0.0-alpha.21/index.cjs'); outputs
|
See also #22652 |
Something changed recently, but it doesn't work yet.
|
I'm just checking whether it was left open by mistake:
|
Deno
Output
How to reproduce
Command
Script
test-native.ts
isThe text was updated successfully, but these errors were encountered: