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/
Kj [/.] Sreekumar programs computers as a hobby and profession. Into programming from his school days, Sree uses Codemarvels to key in facts and fixes he finds interesting while working on different projects. Some of the articles here give away a few shades of his philosophical leanings too.