72

Fix `dyld[]: missing symbol called` errors when running Node.js programs on M1 M...

 2 years ago
source link: https://gist.github.com/adrienjoly/e29a6e73fb7e701eefd80ff9bde9abeb
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Problem

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

Solution

tl;dr: (Re)install a x64 build of Node.js.

Steps to follow

  1. Start a new shell using Rosetta2

    $ arch -x86_64 zsh
  2. 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
  3. Still in that shell, reinstall and build npm dependencies from scratch

    $ rm -rf node_modules
    $ yarn cache clean
    $ yarn install
  4. 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

Troubleshooting

If you still see the error:

  • Try (re)installing your dependencies with npm install instead of yarn install.

  • It could be that the node command is not linked to nvm.

    • To check that, run nvm use 16; nvm ls and check that the little arrow (->) targets v16.
    • If it targets system, you may want to uninstall any other installation of node (e.g. which node; brew uninstall node), then retry the whole procedure.

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK