Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 41 You must be signed in to star a gist
  • Fork 11 You must be signed in to fork a gist
  • 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.
@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) βœ— 

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