Open noldor opened 6 years ago
wow... so npm actually changes the line endings for files listed in package.json "bins". 😞
The npm-scripts-info
package ships with CRLF line endings on all their files. npm changes the one file listed in bins
which in this case is lib/cli.js
:
~/Projects/npm-test 🐒 file node_modules/npm-scripts-info/lib/cli.js
node_modules/npm-scripts-info/lib/cli.js: a /usr/bin/env node script text executable, ASCII text
~/Projects/npm-test 🐒 file node_modules/npm-scripts-info/lib/index.js
node_modules/npm-scripts-info/lib/index.js: ASCII text, with CRLF line terminators
~/Projects/npm-test 🐒 file node_modules/npm-scripts-info/lib/default-info.js
node_modules/npm-scripts-info/lib/default-info.js: ASCII text, with CRLF line terminators
It's unfortunate that npm edits packages and tries to "correct" them instead of encouraging package owners to publish valid packages. But I guess the precedent has been set.
Thanks for reporting this. I'll flag this as a compatibility bug. If you want to work up a PR, we would appreciate it.
edit:
I also checked this on Windows and it looks like npm does not change the line endings for that file. So npm must be converting it to the "normal" line endings for the current OS.
So behaviour should be same with npm?
I would expect the behavior to be the same in npm and yarn. In this case it makes sense for yarn to change to match npm.
I confirm this bug with Ubuntu 17.10 / node v9.11.1 / yarn 1.6.0
. I don't have this bug with npm
as workaround it worked for me dos2unix -F node_modules/.bin/soltsice
(it was the file with CRLF)
Same problem (Ubuntu 18.04, yarn 1.9.4). This issue was opened aboutr 6 months ago; is there any progress?
Just encountered this with json-mock-server
on macos. Bin scripts in that package have crlf endings. When installed and run with npm they work, but when the package is installed with yarn and run either by npm run
or yarn run
, I get the \r
error.
I fixed it with dos2unix -F node_modules/.bin/*
.
I'm guessing the long-term fix for this is to move away from Windows for development. In the meanwhile we can make sure to add the .editorconfig
file in the root, or simply switch the encoding in your VSCode project to generate that file.
It can be something like this:
# All files.
[*]
end_of_line = LF
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = false
Also can be set in GIT > git config --global core.autocrlf false
. But make sure your files in Windows are still only save LF in files, as in .editorconfig
above, or git status will complain.
@rally25rs I'm trying to write a pr to fix this issue~
Note that yarn v1 is no longer under development, other than critical and security fixes. A PR may sit open indefinitely. Everyone is encouraged to look into migrating to yarn v2
Sent from TypeApp
On Oct 14, 2021, 10:49 AM, at 10:49 AM, vagusX @.> wrote: @. I'm trying to write a pr to fix this issue~
-- You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: https://github.com/yarnpkg/yarn/issues/5480#issuecomment-943432971
@rally25rs got it✔️
I had this bug today with vitepress-export-pdf
package, see details here: https://github.com/condorheroblog/vitepress-export-pdf/issues/24
What is the current behavior? After installing npm-scripts-info, all files of this package have CRLF line endings and it cause error:
If the current behavior is a bug, please provide the steps to reproduce.
What is the expected behavior? Expected to have no errors while running script. If install package through npm, it works correct.
Please mention your node.js, yarn and operating system version.