If you're getting this kind of error when running Node.js programs with binary dependencies that don't support M1 yet, e.g.:
$ yarn test
dyld[51175]: missing symbol called
dyld[51176]: missing symbol called
tl;dr: (Re)install a x64 build of Node.js.
-
Start a new shell using Rosetta2
$ arch -x86_64 zsh
-
In that shell, reinstall the
x64
version of Node.js$ nvm use system $ nvm cache clear $ nvm uninstall 16 # or the version you need $ nvm install 16 # or the version you need $ nvm use 16 # or the version you need
-
Still in that shell, reinstall and build npm dependencies from scratch
$ rm -rf node_modules $ yarn cache clean $ yarn install
-
Whenever you come back to your project (e.g. after restarting), don't forget to select that same version of Node.js!
$ nvm use 16 # or the one you installed in step 2
If you still see the error:
-
Try (re)installing your dependencies with
npm install
instead ofyarn install
. -
It could be that the
node
command is not linked tonvm
.- To check that, run
nvm use 16; nvm ls
and check that the little arrow (->
) targetsv16
. - If it targets
system
, you may want to uninstall any other installation ofnode
(e.g.which node; brew uninstall node
), then retry the whole procedure.
- To check that, run
M2 chip here:
For those using
@google-cloud/storage
(orfirebase-admin
storage module), it optionally usesfast-crc32c
which is not compatible with ARM, hence thedyld[...]: missing symbol called
. ([email protected]
at the time of writing).Performance is a concern for us, and we weren't sure whether it was worse to slow down CRC calculation or to slow down all the rest by running unnecessarily under Rosetta.
We decided to get rid of
fast-crc32c
and keep running under ARM. But we haven't really benchmarked yet to make sure it was actually convenient. If anyone has, please advice.EDIT:
That above all happened while we were running under Node 16.
We just migrated to Node 20 and decided to try again using
[email protected]
and it did work under ARM without Rosetta.It didn't under Node 16 π€·ββοΈ Oh, well...