Closed Zvicii closed 1 year ago
Can you show the contents of test.js
?
const test = require('/home/conan/nim-cross-platform-sdk/build/lib/node-nim.node')
console.log('test')
Your error output shows this filename being loaded:
/home/conan/nim-cross-platform-sdk/build/lib/node-nim.node.9.9.2
instead of
/home/conan/nim-cross-platform-sdk/build/lib/node-nim.node
Perhaps that is the cause? Is the latter a symlink to the former or is your code being transformed somehow to require the former?
Sorry I didn't make myself clear,node-nim.node is just a symlink
to node-nim.node.9.9.2. change test.js to
const test = require('/home/conan/nim-cross-platform-sdk/build/lib/node-nim.node.9.9.2')
console.log('test')
has the same output
I believe you need a .node
at the end of the filename for node to treat it as an addon.
I believe you need a
.node
at the end of the filename for node to treat it as an addon.
yes! thats it, so Im actually requiring node-nim.node.9.9.2
which is not ended by .node
.
After changing it to node-nim.node
and remove the symlink, its working now,
Many thanks!
Version
v16.19.1 & v18.14.2
Platform
Linux e0b3b5af329d 5.10.16.3-microsoft-standard-WSL2 #1 SMP Fri Apr 2 22:23:49 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
Subsystem
No response
What steps will reproduce the bug?
I wrote a node addon using node-api, it works fine on Windows and macOS, but on Linux, it reports
SyntaxError
. After browsing though the community and the internet, I found people who are getting the same error.https://github.com/vercel/pkg/discussions/1643 https://github.com/Unitech/pm2/issues/4775
How often does it reproduce? Is there a required condition?
Stable recurrence
I'm testing using ubuntu 1604 with node 16.19.1 and ubuntu 2204 with nodejs 18.14.2. Getting the same error.
What is the expected behavior?
nodejs loads node-nim.node and treat it as a node addon
What do you see instead?
Additional information