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.
@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. (fast-crc32c@2.0.0 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 fast-crc32c@2.0.0 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/bcrypt@5.0.2
 + @types/bun@1.0.4
 + @types/cors@2.8.17
 + @types/express@4.17.21
 + @types/jsonwebtoken@9.0.5
 + @types/node@20.11.10
 + @types/swagger-jsdoc@6.0.4
 + @types/swagger-ui-express@4.1.6
 + ts-node@10.9.2
 + typescript@5.3.3
 + @supabase/supabase-js@2.39.3
 + bcrypt@5.1.1
 + canvas@2.11.2
 + cors@2.8.5
 + dotenv@16.4.1
 + express@4.18.2
 + fs@0.0.1-security
 + https@1.0.0
 + jsonwebtoken@9.0.2
 + multer@1.4.5-lts.1
 + sharp@0.33.2
 + swagger-jsdoc@6.2.8
 + swagger-ui-express@5.0.0

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