Fixing Expo + npm ERR_INVALID_URL and Permission Issues on WSL
Problem Summary
When running Expo inside WSL, npm errors appear such as:
ERR_INVALID_URLexpo: Permission denied
Cause: Windows Node/NPM is being used inside WSL, and Windows-mounted paths block Linux permissions.
Fix Instructions
1. Use WSL Terminal
Open your Linux shell (Ubuntu app) instead of PowerShell/CMD.
2. Ensure Node and npm are Linux-native
Install Node.js inside WSL:
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs
Check:
which node
which npm
Expected: /usr/bin/node and /usr/bin/npm
3. Keep project inside WSL filesystem
Move if currently on Windows mount:
mv /mnt/c/Users/yourname/projects/cma-lokomotif-expo ~/projects/
cd ~/projects/cma-lokomotif-expo
4. Fix missing executable permission
chmod +x ./node_modules/.bin/expo
5. Clean reinstall deps
rm -rf node_modules
npm install
6. Run Expo
npx expo start --no-open
Open the displayed URL manually in a Windows browser if needed.
Notes
- No need to install Expo CLI globally β
npxis enough. - Avoid running
npmcommands from Windows paths (\\wsl.localhost\...).
This setup prevents npm URL resolution errors and file permission issues when developing React Native (Expo) inside WSL.