node.jsnpm-installnpm-package

Issue Installing npm Packages: MaxListenersExceededWarning and Persistent Error


I'm facing an issue while trying to install npm packages, and I'd appreciate some assistance. Here are the details:

Error Message:

(node:1479) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
(Use 'node --trace-warnings ...' to show where the warning was created)

I followed the docs, ran npm i -D @waline/client, and got hit with the above error. To troubleshoot, I started a fresh project with npm init and then tried npm install -g yarn. Surprisingly, same error!

I haven't written a single line of code yet. The error shows up every time I run npm install.

My Setup: Node version: v20.8.1 NPM version: 10.1.0

Can someone help me understand the cause of this issue and provide guidance on resolving it?


Solution

  • Maybe, because of GFW. You should use a proxy.

    In fact, it is indeed because of network problems in mainland China. Even though there may be problems with node. I tested it in Hong Kong and the United States, and no problems were found.

    how to set up npm proxy

    npm config set proxy http://127.0.0.1:1080
    

    OR:

    A proxy to use for outgoing http requests. If the HTTP_PROXY or http_proxy environment variables are set, proxy settings will be honored by the underlying request library.

    how to set up yarn proxy:

    yarn config set httpProxy http://127.0.0.1:1080
    yarn config set httpsProxy http://127.0.0.1:1080
    # You should know the proxy.