Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

press-export-pdf.mjs is generated with CRLF line ends #24

Closed
phortx opened this issue Aug 29, 2024 · 8 comments
Closed

press-export-pdf.mjs is generated with CRLF line ends #24

phortx opened this issue Aug 29, 2024 · 8 comments
Assignees
Labels
bug Something isn't working question Further information is requested

Comments

@phortx
Copy link

phortx commented Aug 29, 2024

Hi,

I discovered that I can't use the press-export-pdf command:

node_modules/vitepress-export-pdf/bin$ ./press-export-pdf.mjs
env: node\r: No such file or directory

While this works:

node_modules/vitepress-export-pdf/bin$ /usr/bin/env node --version
v22.4.1

The \r irritated me and I converted the file from CRLF (Windows) line ends to LF (Unix) line ends and voila:

node_modules/vitepress-export-pdf/bin$ ./press-export-pdf.mjs
press-export-pdf/3.0.3

Usage:
  $ press-export-pdf <command> [options]

Why are there windows line ends in the file? Shouldn't cause this errors on all unix environments? 🤔

I'm on MacOS with yarn and Node 22.4.1.

@condorheroblog condorheroblog self-assigned this Aug 29, 2024
@condorheroblog condorheroblog added bug Something isn't working question Further information is requested labels Aug 29, 2024
@condorheroblog
Copy link
Owner

I'm sorry I didn't reproduce your situation.

image
> press-export-pdf info
  System:
    OS: macOS 14.5
  Binaries:
    Node: 20.15.0
    npm: 10.7.0
  npmPackages:
    vitepress: ^1.1.4 => 1.1.4

@phortx
Copy link
Author

phortx commented Aug 29, 2024

Interesting. When I rm -rf node_modules and run yarn and then file node_modules/vitepress-export-pdf/bin/press-export-pdf.mjs I get [...] ASCII text, with CRLF line terminators (windows line endings).

When I download the file directly from the repo and run file press-export-pdf.mjs I get [...] ASCII text (correct line endings).

So the file in the repo is correct, but the file after installing the package is not.

So I again rm -rf node_modules/ and tried npm i (instead of yarn) and run again file node_modules/vitepress-export-pdf/bin/press-export-pdf.mjs which produces: [...] ASCII text, with CRLF line terminators. Still wrong.

So I installed it globally via npm i -g vitepress-export-pdf and file ~/.asdf/installs/nodejs/22.4.1/lib/node_modules/vitepress-export-pdf/bin/press-export-pdf.mjs says: [...] ASCII text, with CRLF, LF line terminators - looks confusing, but is more correct and (more important): it works.

So looks like this is not a issue of this npm package more maybe some package mangement or local configuration problem. However I don't have this issue with other packages and never had. Very interesting 🤔

@phortx
Copy link
Author

phortx commented Aug 29, 2024

So I narrowed down this issue to the Yarn Registry (ttps://registry.yarnpkg.com).

When I remove my .npmrc (containing registry=https://registry.yarnpkg.com) and reset everything and install again, it works:

$ rm -rf .npmrc yarn.lock package-lock.json node_modules/
$ npm cache clean --force
$ npm i
$ file node_modules/vitepress-export-pdf/bin/press-export-pdf.mjs
[...] ASCII text, with CRLF, LF line terminators 
$ press-export-pdf
press-export-pdf/3.0.3

Usage:
  $ press-export-pdf <command> [options]
[...]

I'm not 100% sure but it seems like to be related to the Yarn Registry 🤔

I close this here for now. Sorry for bothering you!

@condorheroblog
Copy link
Owner

It's great. Have a good trip.🥳

@phortx
Copy link
Author

phortx commented Aug 29, 2024

FYI, I reported it in the yarn repo: yarnpkg/yarn#5480

@condorheroblog
Copy link
Owner

Okay, that's the reason why I don't like Yarn. have you ever tried to use pnpm🎃

I think it's better than Yarn with my opinion 😂

@phortx
Copy link
Author

phortx commented Aug 29, 2024

I started to use yarn years ago when npm generated HUGE node_moduels dirs. Never looked for alternatives. AFAIK ist the node_modules tree issue fixed with npm, so I will just use npm now :)

@condorheroblog
Copy link
Owner

OK 😸

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants