Quantcast
Channel: Npm install cannot find module 'semver' - Stack Overflow
Viewing all articles
Browse latest Browse all 48

Answer by Deven T. Corzine for Npm install cannot find module 'semver'

$
0
0

I encountered this Cannot find module 'semver' error while running npm install in WSL1 under Windows 10, with Ubuntu 22.04.2 LRS (jammy) as the Linux installation.

Using strace to see what syscalls were made, I found that Node.js was looking for /usr/share/nodejs/npm/node_modules/semver/package.json, which didn't exist. However, that module does appear to exist at the top level, in /usr/share/nodejs/semver/package.json. After some experimentation, I found that adding the top-level directory to Node's search path appears to fix the problem. This worked for me:

NODE_PATH=/usr/share/nodejs npm install

Therefore, I've added the environment variable setting to my ~/.bashrc file:

export NODE_PATH=/usr/share/nodejs

Viewing all articles
Browse latest Browse all 48

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>