Par*_*bet 10 javascript node.js npm npm-install npx
当我尝试在 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
Par*_*bet 11
我这样做解决了我的问题,对于任何人回来解决同样的问题:
感谢 Lisheng Ma 和 JSON Derulo 的回答和推荐使用npm doctor
,我成功解决了问题,如下:
我首先运行 npm doctor 并得到以下输出:
Check Value Recommendation/Notes
npm ping ok
npm -v not ok Use npm v10.0.0
node -v ok current: v20.5.1, recommended: v20.5.1
npm config get registry ok using default registry (https://registry.npmjs.org/)
git executable in PATH ok /opt/homebrew/bin/git
global bin folder in PATH ok /opt/homebrew/bin
Perms check on cached files ok
Perms check on local node_modules ok
Perms check on global node_modules ok
Perms check on local bin folder ok
npm ERR! checkFilesPermission Missing permissions on /opt/homebrew/bin/.keepme (expect: executable)
npm ERR! checkFilesPermission Missing permissions on /opt/homebrew/bin/__pycache__/bottle.cpython-310.pyc (expect: executable)
Perms check on global bin folder not ok Check the permissions of files in /opt/homebrew/bin
npm WARN verifyCachedFiles Content garbage-collected: 2266 (1602671184 bytes)
npm WARN verifyCachedFiles Cache issues have been fixed
Verify cache contents ok verified 7508 tarballs
npm ERR! Some problems found. See above for recommendations.
npm ERR! A complete log of this run can be found in: `path name to the log file`
Run Code Online (Sandbox Code Playgroud)
所以我更新了 NPM,并运行了以下命令(我使用的是 macOS):
npm install -g npm@latest
,解决有关 NPM 版本的警告。
sudo chmod +x /opt/homebrew/bin/.keepme /opt/homebrew/bin/__pycache__/bottle.cpython-310.pyc
,解决 doctor 命令输出中的权限错误。
最后,我npm doctor
再次运行,得到以下输出:
Check Value Recommendation/Notes
npm ping ok
npm -v ok current: v10.0.0, latest: v10.0.0
node -v ok current: v20.5.1, recommended: v20.5.1
npm config get registry ok using default registry (https://registry.npmjs.org/)
git executable in PATH ok /opt/homebrew/bin/git
global bin folder in PATH ok /opt/homebrew/bin
Perms check on cached files ok
Perms check on local node_modules ok
Perms check on global node_modules ok
Perms check on local bin folder ok
Perms check on global bin folder ok
Verify cache contents ok verified 7509 tarballs
Run Code Online (Sandbox Code Playgroud)
我认为问题出在权限上,不知道如何!但现在肯定已经修复了。
干杯编码!
归档时间: |
|
查看次数: |
4453 次 |
最近记录: |