Node & M1 Mac: dyld[]: 缺少称为的符号

t30*_*0_9 2 arm node.js npm nvm apple-m1

我真的需要你的帮助。

我在使用 Node (v16.8.0) 和配备 Arm 处理器的 macOS 时遇到问题。每次我想运行这个项目的后端时,我都会得到这个:

dyld[17378]: missing symbol called
Run Code Online (Sandbox Code Playgroud)

我已经关注了另一篇文章的整个讨论。我尝试使用 Rosetta2 为arm 进行全新安装,但如果我运行,node -p "process.arch"我总是会得到x64.

我还尝试过更激进的方法:

  • 删除了所有文件夹和子文件夹中的所有节点文件、所有内容,确保节点已完全卸载
  • 删除了库并删除了依赖项
  • 用brew重新安装Node(使用arch)
  • 重新安装库和依赖项

由于我今天已经删除并重新安装了节点 5 次,您能帮我看看如何解决这个问题吗?谢谢你!

Ana*_*iva 5

来自 @adrienjoly 的这段代码片段解决了这个问题。

    1. Start a new shell using Rosetta2. Rosetta 2 translates apps built for Intel so they will run on Apple Silicon

    $ 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

    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

Run Code Online (Sandbox Code Playgroud)

要点是我们需要在 x64 架构中卸载和安装节点。

我们清除缓存和其他依赖项,以便它们也是与 Node.js 的 x64 版本兼容的版本