npm install module -g Gives MaxListenersExceedWarning

wfauudbj  于 11个月前  发布在  其他
关注(0)|答案(2)|浏览(150)

使用:

  • 节点12.9.0
  • npm 6.10.2
  • macOS莫哈韦

我正在学习一个在线教程,该教程教初学者如何通过发出-g标志来全局安装npm模块:

myapp$ npm i [email protected] -g

字符串
输出量:

(node:26645) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 drain listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
(node:26645) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 drain listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
(node:26645) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 drain listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
(node:26645) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 drain listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
(node:26645) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 drain listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
(node:26645) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 drain listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
(node:26645) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 drain listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
(node:26645) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 drain listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
(node:26645) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 drain listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
(node:26645) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 drain listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
/usr/local/bin/nodemon -> /usr/local/lib/node_modules/nodemon/bin/nodemon.js

> [email protected] install /usr/local/lib/node_modules/nodemon/node_modules/fsevents
> node install

node-pre-gyp WARN Using needle for node-pre-gyp https download 
[fsevents] Success: "/usr/local/lib/node_modules/nodemon/node_modules/fsevents/lib/binding/Release/node-v72-darwin-x64/fse.node" is installed via remote

> [email protected] postinstall /usr/local/lib/node_modules/nodemon
> node bin/postinstall || exit 0

Love nodemon? You can now support the project via the open collective:
 > https://opencollective.com/nodemon/donate

+ [email protected]
added 289 packages from 144 contributors in 13.382s


我是Node.js新手,如何修复/关闭此警告?
我是否必须在所有需要全局安装模块的node.js项目文件中使用Use emitter.setMaxListeners()
这也是我使用sudo时的警告:
sudo npm i [[email protected]](https://stackoverflow.com/cdn-cgi/l/email-protection) -g

qlckcl4x

qlckcl4x1#

我也有这个问题。这是一个bug,似乎在v12.9.1中得到了修复。更新对我来说很有用。

e4yzc0pl

e4yzc0pl2#

在我的场景中,遇到的问题源于网络相关的更改。在过去的两天里,网络基础设施进行了升级,导致官方NPM映像地址https://registry.npmjs.org/不可用。执行npm install时,出现警告:

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

字符串
此警告在一定时间后会出现错误:

Npm ERR! Code ETIMEOUT
Npm ERR! Errno ETIMEOUT
Npm ERR! Network request to https://registry.npmjs.org/npm Failed, reason:
Npm ERR! Network This is a problem related to network connectivity
Npm ERR! Network In most cases you are behind a proxy or have bad network settings
Npm ERR! Network
Npm ERR! Network If you are behind a proxy, please make sure that the
Npm ERR! Network 'proxy' config is set property See: 'npm help config'


要解决此问题,请考虑切换到中国大陆内的备用图像源,例如:

Npm config set registry https://registry.npm.taobao.org // Taobao
Npm config set registry https://mirrors.huaweicloud.com/repository/npm // Huawei


仅供参考

相关问题