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
@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