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

Cannot run directly on linux #2

Closed
undefined-moe opened this issue Mar 13, 2022 · 14 comments
Closed

Cannot run directly on linux #2

undefined-moe opened this issue Mar 13, 2022 · 14 comments

Comments

@undefined-moe
Copy link

嗯...这个 bin.js 它是 CRLF

/usr/bin/env: ‘node\r’: No such file or directory
@cenfun
Copy link
Owner

cenfun commented May 4, 2022

应该不是CRLF的问题
可能是你的linux没有安装node?

@undefined-moe
Copy link
Author

Linux 下并不会对 \r 进行处理,所以 env 会尝试查找一个名为 node\r 的文件(而不是 node
这显然是找不到的。

@cenfun
Copy link
Owner

cenfun commented May 4, 2022

请问用的是哪个linux的版本?

@undefined-moe
Copy link
Author

所有 Linux 版本均为此行为。
但有部分包管理器在全局安装时会对暴露到 bin 段的文件换行符进行自动 patch 操作,而 yarn 不会。

@cenfun
Copy link
Owner

cenfun commented May 4, 2022

This should no longer be a problem since npm@^5.4.0. npm will now auto-convert to the correct line endings. See npm/npm#12371.

https://stackoverflow.com/questions/30344858/node-script-executable-not-working-on-mac-env-node-r-no-such-file-or-directo

如果是这样,所有在windows上publish的包全部都有问题,不可能为了这个去做特殊过滤,请看看上面的这个解答,看看能否解决你的问题

@undefined-moe
Copy link
Author

Related: yarnpkg/yarn#5480

@cenfun
Copy link
Owner

cenfun commented May 4, 2022

image
亲自在Ubuntu测试了没有问题,先close

@cenfun cenfun closed this as completed May 4, 2022
@undefined-moe
Copy link
Author

所有 Linux 版本均为此行为。 但有部分包管理器在全局安装时会对暴露到 bin 段的文件换行符进行自动 patch 操作,而 yarn 不会。

npm 会进行 patch ,但这不是包管理器的通用行为。

@cenfun
Copy link
Owner

cenfun commented May 4, 2022

yarn似乎要被淘汰了
记得一开始用npm,然后yarn牛逼用yarn,现在又用回来npm了,node自带
就一个换行符的问题,这么都不修复,可见还是用回官方的npm好

@cenfun
Copy link
Owner

cenfun commented May 4, 2022

支持的,npm7就开始支持workspace了,比yarn支持还好

@undefined-moe
Copy link
Author

PS C:\Users\pc> node -v
v14.19.0
PS C:\Users\pc> npm -v
6.14.16

摆烂.jpg (

@cenfun
Copy link
Owner

cenfun commented May 4, 2022

npm可以直接升级到8,单独升级即可,node继续用14没问题,不过升级node16也没啥问题,一般都兼容
yarn虽然支持workspace,但还在每个子项目里建一个node_modules目录,link一些文件在里面,就是假的workspace一样,非常烦yarn建一堆的垃圾文件放里面

@undefined-moe
Copy link
Author

个人喜好问题不做评价。据我所知 yarn 在子项目里建 node_modules 有两个原因

  1. 需要保证某些直接读取 node_modules/.bin 的包能够正常跑
  2. 一个工作区的不同包依赖了同一 package 的不同版本,不能全部放进 root

@undefined-moe
Copy link
Author

我不喜欢 npm 主要是它依赖太杂了 不像 yarn 一个单文件清爽(
不过 yarn1 确实已经 EOL 了,yarn2 开始不做 global 了 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants