'Every time I run npm I get this message - Class extends value undefined is not a constructor or null

"Class extends value undefined is not a constructor or null" comes up every time I run npm here's the screenshot

npm


Solution 1:[1]

I came into this same error on Monday morning. Perhaps it was overkill, but my solution was to uninstall npm, remove the /usr/lib/node_modules/npm/node_modules/ directory, and reinstall npm. Everything appears functional now.


To be precise, this is the full error message I saw if I ran npm, like npm --version:

TypeError: Class extends value undefined is not a constructor or null
    at Object.<anonymous> (/usr/lib/node_modules/npm/node_modules/socks-proxy-agent/dist/agent.js:114:44)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/usr/lib/node_modules/npm/node_modules/socks-proxy-agent/dist/index.js:5:33)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/usr/lib/node_modules/npm/node_modules/make-fetch-happen/lib/agent.js:169:25)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)

For what it's worth, I got this error under Arch Linux with a direct install of npm, not using nvm.

Solution 2:[2]

Download fresh node js and press it to install after first next you will see option to remove the existing node js click on that and reinstall it the problem should be solved as it happens to meoption

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 The DIMM Reaper
Solution 2 sudhanshu shaurya