Error: Bindings not found on MacOS / NodeJS 20.16 for for ARM64 (M1/M2/M3 etc.) architecture
Hello, having a bit of a challenging out-of-the box experience here...
How to reproduce:
index.ts:
console.log(process.arch, process.version);
package.json:
{
"name": "test-swc",
"version": "1.0.0",
"description": "",
"scripts": {
"start": "node -r @swc-node/register index.ts",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@swc-node/register": "^1.10.9",
"@types/node": "^22.4.0"
}
}
Node version:
$ node -e 'console.log(process.arch, process.version);'
arm64 v20.16.0
swc-node version: 1.10.9 (see package.json)
Steps to reproduce:
$ npm install
$ npm run start
Expectation: That it output something like arm64 v20.16.0
Reality:
$ npm run start
> [email protected] start
> node -r @swc-node/register index.ts
/Users/macuser/mm/test-swc/node_modules/@swc/core/index.js:255
throw new Error("Bindings not found");
^
Error: Bindings not found
at Compiler.transformSync (/Users/macuser/mm/test-swc/node_modules/@swc/core/index.js:255:15)
at transformSync (/Users/macuser/mm/test-swc/node_modules/@swc/core/index.js:356:21)
at transformSync (/Users/macuser/mm/test-swc/node_modules/@swc-node/core/index.ts:93:26)
at compile (/Users/macuser/mm/test-swc/node_modules/@swc-node/register/register.ts:111:40)
at /Users/macuser/mm/test-swc/node_modules/@swc-node/register/register.ts:122:38
at Module._compile (/Users/macuser/mm/test-swc/node_modules/pirates/lib/index.js:113:29)
at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
at Object.newLoader [as .ts] (/Users/macuser/mm/test-swc/node_modules/pirates/lib/index.js:121:7)
at Module.load (node:internal/modules/cjs/loader:1208:32)
at Function.Module._load (node:internal/modules/cjs/loader:1024:12)
Node.js v20.16.0
If it wasn't clear from arm64 mentioned above, and /Users/macuser paths, the test was on Mac OS Ventura 13.6.7 (22G720), on an M2 chip with the arm64 version of NodeJS 20.16.0.
FWIW on Ubuntu 22.04 Jammy and x84_64 architecture, everything works as expected:
$ npm run start
> [email protected] start
> node -r @swc-node/register index.ts
x64 v20.16.0
Any ideas?
maybe you have to specify @swc/core directly in your package.json. The installation of @swc/core should pull the correct bindings for the platform you are invoking npm install on