env node r No such file or directory
执行 npm scripts
命令突然报错如下:
xx@ling:/usr/github_reps/block-ui# yarn run build:esm
yarn run v1.22.10
$ block-scripts build:component:esm
/usr/bin/env: ‘node\r’: No such file or directory
error Command failed with exit code 127.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
有效信息在第四行 /usr/bin/env: ‘node\r’: No such file or directory
没错~ 后面为啥多了个 \r
回想起当前项目跨平台在开发。Linux 和 Window 都在陆续 pull && push 代码,\r 字符很容易联想到 [End Of Line Sequence]。
随即用 VScode 查看了下,项目文件
node_modules 下执行代码文件
在 linux 环境下统一为 LF 后 scripts 命令成功运行!
CRLF and LF#
CRLF / LF 分别是 Window 和 Unix 系统采用的 End Of Line(EOF) 换行符
CR = Carriage Return (\r, 0x0D in hexadecimal, 13 in decimal)
- moves the cursor to the beginning of the line without advancing to the next line.
LF = Line Feed (\n, 0x0A in hexadecimal, 10 in decimal)
- moves the cursor down to the next line without returning to the beginning of the line.
在打印机时代,使用 CR 把打印机指针移动到行首,LF 把指针往下移动一行。 Unix like 系统为了节省空间等原因里大多采用 LF(\n) 换行,而 Windows 中则延续了打字机时代使用 CRLF 换行。
fix: Prettier#
First available in v1.15.0, default value changed from auto to lf in v2.0.0
Prettier v2+ EOL 的默认配置就是 LF 可以完美解决此问题
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 【自荐】一款简洁、开源的在线白板工具 Drawnix