swc-project / swc-node

Faster ts-node without typecheck
MIT License
1.76k stars 73 forks source link

Cannot find module @swc/core-linux-x64-gnu, Macbook pro with M1 chip #657

Closed ZaxYonatan closed 2 years ago

ZaxYonatan commented 2 years ago

Hi! I'm using Macbook Pro M1. My team has a Dockerfile that runs 'node install...' @swc/core in one of our dependencies and I'm having problems loading '@swc/core-linux-arm64-gnu'

My yarn.lock has both @swc/core-linux-arm64-gnu and @swc/core-linux-x64-gnu (see below) I'm not sure why it tries to load x64 instead of arm64 Thrown error Error: Cannot find module '@swc/core-linux-x64-gnu'

fs.readdirSync("./node_modules/@swc") On my M1 chip: [ 'core', 'core-linux-arm64-gnu', 'core-linux-arm64-musl', 'register' ] On my teammate's intel chip: [ 'core', 'core-linux-x64-gnu', 'core-linux-x64-musl', 'register' ]

yarn.lock `"@swc/core-linux-arm64-gnu@npm:1.2.172": version: 1.2.172 resolution: "@swc/core-linux-arm64-gnu@npm:1.2.172::__archiveUrl=https%3A%2F%2Frepo.dev.wixpress.com%2Fartifactory%2Fapi%2Fnpm%2Fnpm-repos%2F%40swc%2Fcore-linux-arm64-gnu%2F-%2Fcore-linux-arm64-gnu-1.2.172.tgz" conditions: os=linux & cpu=arm64 languageName: node linkType: hard

"@swc/core-linux-x64-gnu@npm:1.2.172": version: 1.2.172 resolution: "@swc/core-linux-x64-gnu@npm:1.2.172::__archiveUrl=https%3A%2F%2Frepo.dev.wixpress.com%2Fartifactory%2Fapi%2Fnpm%2Fnpm-repos%2F%40swc%2Fcore-linux-x64-gnu%2F-%2Fcore-linux-x64-gnu-1.2.172.tgz" conditions: os=linux & cpu=x64 languageName: node linkType: hard`

Thank

Brooooooklyn commented 2 years ago

@ZaxYonatan execute the following command: node -e "console.log(process.arch, process.platform)", and see if your node arch is x64 in your docker env

ZaxYonatan commented 2 years ago

@Brooooooklyn thanks for your quick reply. yes, It prints: x64 linux

Brooooooklyn commented 2 years ago

I'm not sure why it tries to load x64 instead of arm64

So it was because the Node.js in your Docker env is x64 arch, but not sure why you installed core-linux-arm64-gnu' with the x64 Node.js

ZaxYonatan commented 2 years ago

Cool, I'll check it. Thanks a lot :)