tapio / live-server

A simple development http server with live reload capability.
http://tapiov.net/live-server/
4.4k stars 484 forks source link

Bug: `/usr/bin/env: ‘node\r’: No such file or directory` #394

Open christopher-besch opened 2 years ago

christopher-besch commented 2 years ago

The file /home/chris/.config/yarn/global/node_modules/live-server/live-server.js seems to be using Windows line endings (\r\n). Running dos2unix on this file fixes the issue. I installed live-server with yarn global add live-server and yarn version 1.22.17.

Software details

This might be a problem with yarn on Gentoo. Thanks for your help!

christopher-besch commented 2 years ago

This problem is related: https://github.com/yarnpkg/yarn/issues/8106

mattrossman commented 2 years ago

Strangely, the file on GitHub appears to use LF endings, but the one that appears in node_modules installed from the npm Registry uses CRLF. I tried to fork & fix the issue, but I see LF already there in the source. Maybe something weird happened during the latest publish?

So, another workaround is to list the latest version from GitHub as a dependency:

"devDependencies": {
  "live-server": "git+https://github.com/tapio/live-server.git#ad22544",
}
christopher-besch commented 2 years ago

yarn global add git+https://github.com/tapio/live-server.git#ad22544 fixes the issue. Thanks a lot, @mattrossman!

dominicarrojado commented 2 years ago

Happen to me as well, the issue doesn't happen with previous version 1.2.1

mattrossman commented 2 years ago

@tapio could you please re-publish the latest version without changing the line endings? I was bitten by this again when installing on a new machine.

uaru commented 1 year ago

yarn global add git+https://github.com/tapio/live-server.git#ad22544 fixes the issue.

For zsh you need quotes.

yarn global add 'git+https://github.com/tapio/live-server.git#ad22544'

chavinlo commented 1 year ago

for npm package manager:

apt-install dos2unix
dos2unix  /usr/local/lib/node_modules/live-server/*
kiprasmel commented 1 year ago

1.2.1 is fine, 1.2.2 is broken

npm i -g live-server@1.2.1
AriPerkkio commented 1 year ago

It seems that 1.2.2 was published from a machine using CRLF line endings. Version 1.2.1 indeed works. PR #404 should prevent these in future.

$ grep version node_modules/live-server/package.json
  "version": "1.2.2",
$ file node_modules/.bin/live-server 
node_modules/.bin/live-server: a /usr/bin/env node script text executable, ASCII text, with very long lines (374), with CRLF line terminators

$ grep version node_modules/live-server/package.json
  "version": "1.2.1",
$ file node_modules/.bin/live-server 
node_modules/.bin/live-server: a /usr/bin/env node script text executable, ASCII text, with very long lines (374)

I guess this package is published from local machine instead of CI? That's not good...

nite commented 1 year ago

It seems that 1.2.2 was published from a machine using CRLF line endings. Version 1.2.1 indeed works. PR #404 should prevent these in future.

Should this be merged?

thescientist13 commented 9 months ago

Just ran into this as well. Pinning to 1.2.1 as suggested resolved the issue for me.

kylebakerio commented 5 months ago

Running into this... was in 1.2.2, also in 1.2.1, but only when using the --port option...? on a linux machine. doesn't seem to be a problem for coworker on his windows machine.