Problem:
We get this error when we do npm install –
Error: Cannot find module ‘semver’
Require stack:
- /usr/share/npm/lib/utils/unsupported.js
- /usr/share/npm/bin/npm-cli.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:924:15)
at Function.Module._load (node:internal/modules/cjs/loader:769:27)
at Module.require (node:internal/modules/cjs/loader:996:19)
at require (node:internal/modules/cjs/helpers:92:18)
at Object. (/usr/share/npm/lib/utils/unsupported.js:2:14)
Reason:
Version issues
Fix:
Run these commands
sudo rm -rf /usr/local/bin/npm /usr/local/share/man/man1/node* ~/.npm sudo rm -rf /usr/local/lib/node* sudo rm -rf /usr/local/bin/node* sudo rm -rf /usr/local/include/node* sudo apt-get purge nodejs npm sudo apt autoremove sudo apt-get install nodejs npm
Try now. Should be fixed !
Note: In case the version didn’t get updated even after following the above command use these set of commands:
sudo rm -rf /usr/local/bin/npm /usr/local/share/man/man1/node* ~/.npm sudo rm -rf /usr/local/lib/node* sudo rm -rf /usr/local/bin/node* sudo rm -rf /usr/local/include/node* sudo apt-get purge nodejs npm sudo apt autoremove Download the latest installable archive for your OS from https://nodejs.org/en/download/ tar -xf your-archiveFile sudo mv extracted-archiveFolder-name/bin/* /usr/local/bin/ sudo mv extracted-archiveFolder-name/lib/node_modules/ /usr/local/lib/

Sreekumar (KJ) has been a hobby programmer from school days. Codemarvels is his personal blog from the year 2010, where he writes about technology, philosophy, society and a bit about physics.
He now runs a conversational AI company – DheeYantra – focusing his efforts to help businesses improve operational efficiency using digital employees powered by AI.
Leave a Reply