在 MacBook Air m1 的 VScode 中的 Node 中运行 JS 文件时出错

问题描述 投票:0回答:1

最近我们有一个黑客马拉松,我们必须使用 PostgreSQL,所以当我使用 Homebrew 将其安装到我的 Macbook 中后,我尝试在终端中运行 JS 文件(已经安装了 NodeJS),但它显示了此错误。

> dyld[33088]: Library not loaded: /opt/homebrew/opt/icu4c/lib/libicui18n.73.dylib
  Referenced from: <FA9BB294-03DF-3FB7-A7BF-EC2FCC767823> /opt/homebrew/Cellar/node/21.6.2/bin/node
  Reason: tried: '/opt/homebrew/opt/icu4c/lib/libicui18n.73.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/opt/icu4c/lib/libicui18n.73.dylib' (no such file), '/opt/homebrew/opt/icu4c/lib/libicui18n.73.dylib' (no such file), '/opt/homebrew/Cellar/icu4c/74.2/lib/libicui18n.73.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/Cellar/icu4c/74.2/lib/libicui18n.73.dylib' (no such file), '/opt/homebrew/Cellar/icu4c/74.2/lib/libicui18n.73.dylib' (no such file)
zsh: abort

节点“/Users/omswaroopnayak/Desktop/vscode/webd/server.js”

我输入了

omswaroopnayak@Oms-MacBook-Air webd % node "/Users/omswaroopnayak/Desk top/vscode/webd/server.js"
(在 VScode 中使用代码运行器)

我期望服务器运行并在终端中输出相同的内容,但我得到了这个。

> dyld[33088]: Library not loaded: /opt/homebrew/opt/icu4c/lib/libicui18n.73.dylib
  Referenced from: <FA9BB294-03DF-3FB7-A7BF-EC2FCC767823> /opt/homebrew/Cellar/node/21.6.2/bin/node
  Reason: tried: '/opt/homebrew/opt/icu4c/lib/libicui18n.73.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/opt/icu4c/lib/libicui18n.73.dylib' (no such file), '/opt/homebrew/opt/icu4c/lib/libicui18n.73.dylib' (no such file), '/opt/homebrew/Cellar/icu4c/74.2/lib/libicui18n.73.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/Cellar/icu4c/74.2/lib/libicui18n.73.dylib' (no such file), '/opt/homebrew/Cellar/icu4c/74.2/lib/libicui18n.73.dylib' (no such file)
zsh: abort
      node "/Users/omswaroopnayak/Desktop/vscode/webd/server.js"
was shown
javascript node.js postgresql macos homebrew
1个回答
0
投票

几天前,当 VS Code 在预提交挂钩期间尝试运行

npm run lint
时,我开始在 VS Code 中遇到相同的错误。当时我唯一改变的是我安装了
oci-cli
homebrew Formula,这是一个基于 python 的 CLI 工具,卸载它并没有解决问题,所以我不能 100% 确定是否这就是原因。

升级所有自制程序包后问题得到解决:

brew upgrade

如果您现在不想升级所有自制程序包,我建议您首先尝试仅升级

node
。我的从
21.6.2 -> 21.7.1
升级了:

brew upgrade node

如果这不能解决问题,这里是我的系统上升级的软件包的完整列表:

go 1.22.0 -> 1.22.1
gh 2.44.1 -> 2.45.0
libpng 1.6.42 -> 1.6.43
vercel-cli 33.5.1 -> 33.5.5
libunistring 1.1 -> 1.2
glib 2.78.4 -> 2.80.0
c-ares 1.26.0 -> 1.27.0
xz 5.6.0 -> 5.6.1
libnghttp2 1.59.0 -> 1.60.0
sqlcmd 1.5.0 -> 1.6.0
libpq 16.2 -> 16.2_1
python-typing-extensions 4.9.0 -> 4.10.0
pcre2 10.42 -> 10.43
node 21.6.2 -> 21.7.1
git 2.43.2 -> 2.44.0

检查您是否安装了这些软件包,如果有,请尝试升级它们。您可以看到已安装的软件包/版本的列表:

brew list --versions | sort
© www.soinside.com 2019 - 2024. All rights reserved.