Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save adrienjoly/e29a6e73fb7e701eefd80ff9bde9abeb to your computer and use it in GitHub Desktop.
Save adrienjoly/e29a6e73fb7e701eefd80ff9bde9abeb to your computer and use it in GitHub Desktop.
Fix `dyld[]: missing symbol called` errors when running Node.js programs on M1 Macs (apple silicon)

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.
@aridder
Copy link

aridder commented Mar 27, 2022

Thank you. Helped a lot

@adrienjoly
Copy link
Author

adrienjoly commented Mar 27, 2022

hi this doesnt work. i already followed the steps that you explain. any tips?

Does the same program work on a x64 (i.e. non-M1) machine, @galihcitta?

If not, although the error message is the same, this solution may be useless in your case. Example of another problem causing a similar error message: https://discourse.julialang.org/t/how-can-i-configure-pkg-to-use-specific-git/71420.

Good luck! πŸ’ͺ

@nescroft
Copy link

nescroft commented Aug 2, 2022

i'm not using NVM and didn't feel like messing with my node installation. i realized i was trying to deploy my code from the terminal inside vscode. when i opened a new mac terminal outside of vscode with settings "open with rosetta in get info" then it worked. something to do with "fast-crc32c" unable to link without x64.

EDIT: a little over a year later I had this issue again on a new M1 primarily running arm. I am using the "n" version manager so the command i needed was "n --arch x64 <whatever_version_you_want>" in a rosetta terminal.

@benjifriedman
Copy link

I don't know why, but after going through the steps, deleting node_modules and package-lock.json, using yarn instead of npm worked for me

@tgensol
Copy link

tgensol commented Aug 7, 2022

@nescroft I had the same issue with fast-crc32c, thank you :)

@RolfHausen
Copy link

this is not allways true, as the error missing symbol called can also mean that you just missing a .cpp file in your binding.gyp so that a symbol is defined but not implemented or initialized.

To make sure your issue is not because of the processor infrastructure (arm / intel and so on) just try your code on an x64 plattform
if the error persists then you may have truly a symbol which is just missing by the linker or by calling.

@thisisarjuns
Copy link

hi this doesnt work. i already followed the steps that you explain. any tips? Screen Shot 2022-03-25 at 01 58 01

Hey were you able to solve this issue? i am facing the same issue

@RolfHausen
Copy link

@thisisarjuns i see an error message right before the missing symbol called in your screenshot mentioning something about sequelize deprecated. maybe you need to solve this first.

the missing symbol called simply means that your linker can not resolve a symbol within a native library
that means something is not declared properly. So as mentioned, check if you have included all needed sourcefiles in your binding.gyp
in my case i was missing a .cpp file within it.

c++ specific:
if you thinking that there is nothing missing, check within the code of the native library if
you have declared all of your static variables within your implementation file
you need to have them not only defined in the header but also declared in the .cpp file

general feedback:
i did a project using mac making a c++ native library and used it with nodejs via npm and included it with require in my js file.
i got this error too and stumbled upon lots of suggestions this should be a architecture issue with arm64. But my experience shows even with an M1 i use here it works fine! you just have a worse error message not telling what is missing. So you need to review your native code carefully. in best make a question on stackoverflow and let a different user look on your code to maybe find the issue.

which is the same i did here: https://stackoverflow.com/questions/73580576/dyld49745-missing-symbol-called-using-c-swig-with-node-js-by-calling-a-funct

@thisisarjuns
Copy link

@RolfHausen - you are right, was an issue with the deprecated feature in sequelize, i have upgraded the node version and it solved the issue πŸ™‚

@caiobozato
Copy link

Just a comment: for me the solution wasn't working when using MacOS Monterey, but after upgrading to MacOS Ventura it worked. But again, I had to follow all steps.

@pushpanktugnawat
Copy link

Noicceeeee worked for me as well, Thanks for all the steps.

@ramu-actyv
Copy link

@adrienjoly 's solution works for me.

@nkiesel
Copy link

nkiesel commented Mar 8, 2023

Another option is to use fnm (install using brew install fnm), and then use fnm --arch x64 install 16

@danielkochengineer
Copy link

@adrienjoly works perfectly for me even for node 18.

@suryapandian
Copy link

I am getting this problem while working on rust code.

@Ahmadre
Copy link

Ahmadre commented Oct 11, 2023

Works perfectly ❀️ even for node 18

@selvarajshanmugam
Copy link

selvarajshanmugam commented Nov 2, 2023

I am getting this problem when run with node 18.18.2 Mac M1 chip . Anyone could help to resolve this issue?
dyld[68363]: missing symbol called

@windowye
Copy link

Works perfectly for node 14.21.3 on Mac M2 chip

@IPv6
Copy link

IPv6 commented Dec 5, 2023

Worked well for node 16 on M2!

"firebase-store" started to work as expected in my project, without "dyld[...]: missing symbol called" crash :)

@maganap
Copy link

maganap commented Jan 25, 2024

M2 chip here:

For those using @google-cloud/storage (or firebase-admin storage module), it optionally uses fast-crc32c which is not compatible with ARM, hence the dyld[...]: 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...

@stepbystepcode
Copy link

not work 😒

(base) ➜  server git:(main) βœ— bun ./src/index.ts
dyld[25666]: missing symbol called
[1]    25666 killed     bun ./src/index.ts
(base) ➜  server git:(main) βœ— arch -x86_64 zsh
(base) ➜  server git:(main) βœ— nvm use system
Now using system version of node: v21.6.0 (npm v10.2.4)
(base) ➜  server git:(main) βœ— nvm cache clear
nvm cache cleared.
(base) ➜  server git:(main) βœ— nvm uninstall v21.6.0
N/A version is not installed...
(base) ➜  server git:(main) βœ— nvm install v21.6.0 
Downloading and installing node v21.6.0...
Downloading https://nodejs.org/dist/v21.6.0/node-v21.6.0-darwin-x64.tar.xz...
################################################################################ 100.0%
Computing checksum with shasum -a 256
Checksums matched!
Now using node v21.6.0 (npm v10.2.4)
(base) ➜  server git:(main) βœ— nvm use v21.6.0     
Now using node v21.6.0 (npm v10.2.4)
(base) ➜  server git:(main) βœ— rm -rf node_modules    
(base) ➜  server git:(main) βœ— bun i       
[0.25ms] ".env.local"
bun install v1.0.24 (6fa35839)

 + @types/[email protected]
 + @types/[email protected]
 + @types/[email protected]
 + @types/[email protected]
 + @types/[email protected]
 + @types/[email protected]
 + @types/[email protected]
 + @types/[email protected]
 + [email protected]
 + [email protected]
 + @supabase/[email protected]
 + [email protected]
 + [email protected]
 + [email protected]
 + [email protected]
 + [email protected]
 + [email protected]
 + [email protected]
 + [email protected]
 + [email protected]
 + [email protected]
 + [email protected]
 + [email protected]

warn: canvas's install script took 5m11.2s

 241 packages installed [312.43s]
(base) ➜  server git:(main) βœ— 
(base) ➜  server git:(main) βœ— 
(base) ➜  server git:(main) βœ— 
(base) ➜  server git:(main) βœ— 
(base) ➜  server git:(main) βœ— 
(base) ➜  server git:(main) βœ— 
(base) ➜  server git:(main) βœ— 
(base) ➜  server git:(main) βœ— bun ./src/index.ts   
1 | 'use strict'
2 | 
3 | const bindings = require('../build/Release/canvas.node')
          ^
TypeError: dlopen(/Users/stepbystep/Documents/typing-app/server/node_modules/canvas/build/Release/canvas.node, 0x0001): tried: '/Users/stepbystep/Documents/typing-app/server/node_modules/canvas/build/Release/canvas.node' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/stepbystep/Documents/typing-app/server/node_modules/canvas/build/Release/canvas.node' (no such file), '/Users/stepbystep/Documents/typing-app/server/node_modules/canvas/build/Release/canvas.node' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64'))
      at /Users/stepbystep/Documents/typing-app/server/node_modules/canvas/lib/bindings.js:3:7
      at /Users/stepbystep/Documents/typing-app/server/node_modules/canvas/lib/canvas.js:9:7
      at /Users/stepbystep/Documents/typing-app/server/node_modules/canvas/index.js:1:7
(base) ➜  server git:(main) βœ— 

@yuannight
Copy link

niubi

@houskii
Copy link

houskii commented Jul 25, 2024

good it's work for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment