Cannot run NPM Commands

Not my solution, but this seemed to work for me. Appears that having the Windows folder structure in $PATH while using WSL2 was causing that parse error, but I’m not exactly sure why.

  1. Go to your user root (cd ~)
  2. Open .bashrc in your chosen editor (vi, nano, etc.)
  3. Append to the end of the file: export PATH=$(echo "$PATH" | sed -e 's/:\/mnt[^:]*//g') # strip out problematic Windows %PATH%
  4. Close and re-open all terminal windows

Source: https://hackmd.io/@badging/wsl2#Troubleshooting-PATH


Updated: Per Lh Lee’s comment, I’ve updated the regex from s/:\/mnt.*//g to s/:\/mnt[^:]*//g as this avoids accidentally capturing anything extra after the problematic /mnt paths.

Whereas the first regex will match /mnt/c/blah:/other/thing, the new one will not.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)