live-server icon indicating copy to clipboard operation
live-server copied to clipboard

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

Open christopher-besch opened this issue 2 years ago • 12 comments

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

  • Command line used for launching live-server: live-server
  • OS: Gentoo Base System release 2.7
  • Browser (if browser related):
  • Node.js version: v14.19.0
  • live-server version: 1.2.2

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

christopher-besch avatar May 15 '22 12:05 christopher-besch

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

christopher-besch avatar May 15 '22 12:05 christopher-besch

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",
}

mattrossman avatar May 17 '22 03:05 mattrossman

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

christopher-besch avatar May 17 '22 16:05 christopher-besch

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

dominicarrojado avatar May 25 '22 02:05 dominicarrojado

@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.

mattrossman avatar Jun 28 '22 15:06 mattrossman

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'

uaru avatar Sep 06 '22 01:09 uaru

for npm package manager:

apt-install dos2unix
dos2unix  /usr/local/lib/node_modules/live-server/*

chavinlo avatar Sep 20 '22 04:09 chavinlo

1.2.1 is fine, 1.2.2 is broken

npm i -g [email protected]

kiprasmel avatar Nov 08 '22 23:11 kiprasmel

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...

AriPerkkio avatar Dec 03 '22 10:12 AriPerkkio

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?

nite avatar Feb 08 '23 18:02 nite

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

thescientist13 avatar Nov 16 '23 16:11 thescientist13

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.

kylebakerio avatar Mar 12 '24 21:03 kylebakerio