DEV Community

Darragh O'Riordan
Darragh O'Riordan

Posted on • Originally published at darraghoriordan.com on

Fixing "env: node : 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 on mac can’t run the script as expected.

env: node\r: No such file or directory
Enter fullscreen mode Exit fullscreen mode

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.

This example fixes line endings in the jira-prepare-commit-msg package.

  "prepare": "npx crlf --set=LF node_modules/.bin/jira-prepare-commit-msg"
Enter fullscreen mode Exit fullscreen mode

Top comments (0)