【问题标题】:'sed' is not recognized as an internal or external command (Windows 10)'sed' 未被识别为内部或外部命令 (Windows 10)
【发布时间】:2020-04-19 21:54:04
【问题描述】:

我正在使用由 yarn 运行的 JavaScript 应用程序。我在运行yarn run dev 时发现了问题。它显示以下错误。

yarn run v1.21.1
$ yarn fixlitepicker && rm -rf .cache/ dist/
$ sed -i 's/# sourceMappingURL/ sourceMappingURL/g' node_modules/litepicker/dist/js/main.js
'sed' is not recognized as an internal or external command,
operable program or batch file.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

我知道它来自package.json 脚本。

"scripts": {
    "dev": "parcel src/index.html",
    "build": "yarn install && yarn fixlitepicker && parcel build src/index.html",
    "prebuild": "rm -rf dist",
    "predev": "yarn fixlitepicker && rm -rf .cache/ dist/",
    "fixlitepicker": "sed -i 's/# sourceMappingURL/ sourceMappingURL/g' node_modules/litepicker/dist/js/main.js"
  },

我已经从here 下载了SED 并安装了它。安装位置C:\Program Files (x86)\GnuWin32。但它不起作用。我看到了同样的问题。我不明白如何解决这个问题。

系统

操作系统Windows 10 Pro
操作系统版本1909
操作系统系统类型64-bit operating system, x64-based processor .

【问题讨论】:

  • 显然该脚本是为类 Unix 平台编写的。你能在这里摆脱 Windows 吗? (稍后你会感谢我的。)
  • 尝试从 GNU shell 终端环境(v.gr. bash)而不是 Windows 命令行运行 yarn 命令。
  • 当我搜索您的主题行的确切文本时,这里还有 22 个其他 Q/A。如果从该搜索中删除 sed is,则有 6000 多个其他 Q/A 处理该主题。您是否查看了这些消息以帮助解决您的问题?请做,祝你好运。

标签: windows sed windows-10 yarnpkg gnuwin32


【解决方案1】:

你有没有设置这里提到的HOME目录,http://gnuwin32.sourceforge.net/install.html

如果不能修复,请安装http://cygwin.com/ 并试一试

【讨论】:

  • 感谢您的回答。 Cygwin 终端工作但 GnuWin32 有错误。
【解决方案2】:

您从 GnuWin32 下载并安装了“sed”,但它不在您的路径上。 您需要在将C:\Program Files (x86)\GnuWin32 添加到PATH 的终端中运行。您可能还可以从安装“which”中受益,然后您可以使用which sed 进行健全性检查

【讨论】:

    猜你喜欢
    • 2020-12-09
    • 2017-11-13
    • 1970-01-01
    • 1970-01-01
    • 2019-03-25
    • 2018-04-24
    • 2017-06-29
    • 1970-01-01
    • 2016-11-29
    相关资源
    最近更新 更多