cli.js has a shebang with unsupported CRLF line endings
Closed this issue · 4 comments
The cli.js
file uses the shebang #!/usr/bin/env node
as well as CRLF line endings. This does not work in many Unix-like operating systems, macOS being one of them. It will basically complain that node\r
does not exist.
Since the shebang references a UNIX path I suspect it is not intentional to use CRLF and that using LF is a solution to the issue.
Hey @AlexGustafsson thank you for reporting this! Since I am using Windows on my personal machine, your suspicion sounds correct! Unfortunately, I do not have easy access to a Mac, so would not be able to test a fix for this. Would you be able to supply a tested PR, and I will be happy to merge & release.
Turns out Git by default handles this quite gracefully by applying automatic normalization of line-endings. NPM, uses the exact files that are published. So changes I make wouldn't necessarily help. The simplest way to solve it seems to be for you to ensure that the cli.js
file uses LF (at the very least for the first line) and publish a new version to NPM after making sure it still works on Windows.
Another option is to have a wrapper script such as cli.sh
which just runs node cli.js
with all the arguments it's given. This file may then be marked in a .gitattributes
file to always be LF - regardless of Git settings. Then this script may be used instead of cli.js
in package.json
as the "binary".
One thing I might suggest is setting the following options in Git:
core.autocrlf=false
core.eol=lf
This will force Git to not normalize line endings on Windows and instead upload them as is, with a preference to LF
instead of CRLF
. That would at least solve the issue of the files being committed/checked out with CRLF
line endings.
As for testing I'd recommend Windows Subsystem for Linux (WSL). It's very easy to set up and exhibits the same problem as Mac does when it comes to line endings.
This should now have been fixed in 0abe402 and published to npm as v1.4.2
The file now looks like this on both Windows and Linux, both in the repo and after npm install
Closing this, but please comment if you still have issues with this.