The error message suggests that the script you're invoking has
embedded \r
characters, whichThis problem is mentioned in turn suggests that it has
Windows-style \r\n
line endings, instead of the Linux-stylefollowing sources, where various
\n
-only line endings thatsolutions were suggested:
- After installing npm on WSL Ubuntu 20.04 I get the message "/usr/bin/env: ‘bash\r’: No such file or directory"
- /usr/bin/env: ‘bash\r’: No such file or directory: Incompatible line-endings (WSL?) #1725
This might be enough bash
expects.:
- From WSL run
sudo apt install nodejs npm
to install node & npm - From PowerShell/CMD run
wsl --shutdown
to restart the WSL service - Next in WSL run
which npm
to confirm it's installed [output: /usr/bin/npm]
As a quick fixIf this doesn't solve the issue, you can removeother solutions are suggested
in the \r
charsabove sources. as follows:
sed $'s/\r$//' input-file > output-file