Code Monkey home page Code Monkey logo

Comments (11)

System233 avatar System233 commented on June 10, 2024 1

I checked cli.js in the repository before and this file is correct, there is no CR newline in it, CR newline only appears in npm packages.
CR newlines may affect shebang instructions in linux, this discussion explains the issue:
https://unix.stackexchange.com/questions/108588/shebang-line-not-working-with-cr-lf

from bytenode.

OsamaAbbas avatar OsamaAbbas commented on June 10, 2024

I haven't used Notepad in years. If your diagnosis is correct, it might be Git for Windows that injected those characters.

I will check and publish a fix now.

from bytenode.

OsamaAbbas avatar OsamaAbbas commented on June 10, 2024

I cannot find any \r characters in cli.js file. Also, the version 1.5.4 works properly on my linux machine.

image

from bytenode.

System233 avatar System233 commented on June 10, 2024

I cannot find any characters in file. Also, version works properly on my linux machine.\r``cli.js``1.5.4

image

That's weird, take a look at this file, it's from version 1.5.4 in npm: https://www.npmjs.com/package/bytenode/file/67b5f06b0fb3f124eed4c381c2515e315fb32637052f933954162a2ba703db15
image

cli.js in v1.5.3:
image

from bytenode.

System233 avatar System233 commented on June 10, 2024

npm pack [email protected]
Try this command to download the tar.gz package, and then check the cli.js file inside. I can see that CRLF newlines are indeed used in it.

image

from bytenode.

System233 avatar System233 commented on June 10, 2024

Anyway v1.5.4 will not work in the node:21-alpine3.19 container, just because there are CR newlines in it.

from bytenode.

OsamaAbbas avatar OsamaAbbas commented on June 10, 2024

That's weird, take a look at this file, it's from version 1.5.4 in npm: https://www.npmjs.com/package/bytenode/file/67b5f06b0fb3f124eed4c381c2515e315fb32637052f933954162a2ba703db15

I downloaded this file, and again, I cannot find any \r characters in it.

npm pack [email protected]
Try this command to download the tar.gz package

Again, I downloaded the package, and no \r in there.

The images you provided shows that the file is auto-detected to have CR+LF newlines. However, if you actually search for \r, you will find none.

Anyway v1.5.4 will not work in the node:21-alpine3.19 container, just because there are CR newlines in it.

I tested Node v20.x on my machine. I will test Node v21.x later and get back to you.

from bytenode.

System233 avatar System233 commented on June 10, 2024

This is not possible, maybe you can try to use hex editor or xxd command to view the file in hex mode.

VSCODE HEX EDITOR

image

XXD

$ md5sum cli.js
ed03d365e1dfd03aedc768663b77c569 *cli.js
$ xxd cli.js
00000000: 2321 2f75 7372 2f62 696e 2f65 6e76 206e #!/usr/bin/env n
00000010: 6f64 650d 0a0d 0a27 7573 6520 7374 7269 ode....'use stri
00000020: 6374 273b 0d0a 0d0a 636f 6e73 7420 6673 ct';....const fs
00000030: 203d 2072 6571 7569 7265 2827 6673 2729 = require('fs')
00000040: 3b0d 0a63 6f6e 7374 2070 6174 6820 3d20 ;..const path =
00000050: 7265 7175 6972 6528 2770 6174 6827 293b require('path');

from bytenode.

System233 avatar System233 commented on June 10, 2024

Reproducible environment:

ENV

Docker Desktop+WSL2
Docker version 25.0.3, build 4debf41
WSL version : 2.1.4.0
kernel version : 5.15.146.1-2
WSLg version : 1.0.60
MSRDC version : 1.2.5105
Direct3D version : 1.611.1-81528511
DXCore version : 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version : 10.0.22631.3155

Dockerfile:

FROM node:21-alpine3.19 
RUN yarn global add bytenode
WORKDIR /app

SHELL

docker build . -t app
docker run -it app:latest sh

/app # vi /usr/local/bin/bytenode ## saw CR newlines(^M)
/app # bytenode -v
': No such file or directory
/app #

from bytenode.

OsamaAbbas avatar OsamaAbbas commented on June 10, 2024

This is weird. The md5sum cli.js from the package is indeed ed03d365e1dfd03aedc768663b77c569. However, if you clone the repository and run md5sum cli.js, it is fbea827b80fab18279151221306b238e.

Now, the most likely reason is that my Git was configured to automatically add CRLF upon checkout and commit LF. So, no CR characters were leaked into the git repository. However, when I used npm publish, it packed the local version where the CR characters exist.

But, this does not explain why the version 1.5.4 works on my machine. Maybe it's docker related issue?

Anyways, I published a new version now 1.5.5. Let me know if it fixes your issue.

from bytenode.

System233 avatar System233 commented on June 10, 2024

I tested the v1.5.5 version and now it works fine in the environment, GREAT!
Thank you for the great work!

Dockerfile:

FROM node:21-alpine3.19 as init-env
RUN yarn global add [email protected]
docker run -it test sh
/ # bytenode -v
bytenode 1.5.5
Node 21.7.0
/ # vi /usr/local/bin/bytenode ## NO CR newlines now;

from bytenode.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.