在 macOS 上安装或创建 Node.js 项目时出现 MaxListenersExceededWarning

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

当我尝试在 macOS (darwin) 上安装或创建 Node.js 项目时,收到以下警告消息:

(node:80101) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit

在多次看到警告后,我已将 Node.js 更新到最新版本(V20.5.1),并且 npm 已经是最新版本(V9.8.1)。我没有使用任何第三方工具,我只是使用终端。

我收到警告后的命令是:

npm install ...
npx ...

执行这些命令后我至少收到一次警告消息(通常是多次)。

我正在从事的项目甚至没有 NodeJS 文件,两次我都忙于 React 和下一个项目(我认为这无关紧要,因为在任何项目之外的终端中使用 NPM 时我都会看到相同的警告)。

如果有人能帮助我,我将不胜感激。 到目前为止,除了警告本身之外,我还没有注意到项目或安装过程中有任何问题,但我不明白为什么当我没有对 NPM 或节点中的任何配置进行任何更改时会弹出警告。

尝试使用 NPM 安装软件包并使用 NPX 创建项目,这两者都会导致相同的警告(有时在安装或创建过程完成之前多次):

(node:80101) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit

javascript node.js npm npm-install npx
1个回答
0
投票

这是我的解决方案: 运行 npm 医生 并解决所有问题

确保您的注册表是 https://registry.npmjs.org/ 并且 /opt/homebrew/bin/.keepme 是可执行的

© www.soinside.com 2019 - 2024. All rights reserved.