Fixing "env: node\r: No such file or directory" on mac for an npm package
If you install an npm package using yarn and you get this error it means that the package author is using windows line endings and Node.js on mac can't run the script as expected.
env: node\r: No such file or directory
To fix it you need to change the line endings. But you need to ensure this happens after each install of packages!
How to change line endings on npm package install
Note: You won't get this error if you use npm because npm automatically processes the line endings for you!
The trick for us yarn users is to use the crlf
package to modify the line endings for the package.
You can add a script to the prepare script. This will be run after every install.
"prepare": "npx crlf --set=LF node_modules/.bin/jira-prepare-commit-msg"