“sed”在Windows 10中未被识别为内部或外部命令。

3
我正在使用一个由 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"
  },

我已经从这里下载了SED并安装。安装位置为C:\ Program Files(x86)\ GnuWin32 。但它不起作用。我遇到了同样的问题。我不知道如何解决这个问题。 系统 操作系统Windows 10专业版。
操作系统版本1909 。
操作系统类型64位操作系统,x64-based processor。

enter image description here


2
显然,这个脚本是为类Unix平台编写的。你能在这里摆脱Windows吗?(以后你会感谢我的。) - undefined
尝试在GNU shell 终端环境(例如 bash)中运行 yarn 命令,而不是在 Windows 命令行中运行。 - undefined
当我搜索你的主题行的确切文本时,这里还有22个其他的问答。如果从搜索中删除sed is,则还有6000多个与这个主题相关的问答。你是否阅读了这些信息来帮助解决你的问题?请务必查看并祝你好运。 - undefined
将代理从'windows-latest'更改为'ubuntu-latest'解决了问题。感谢@tripleee。 - undefined
2个回答

2

感谢您的回答。Cygwin终端可以正常工作,但GnuWin32出现错误。 - undefined

0
你从GnuWin32下载并安装了'sed',但它并没有添加到你的路径中。 你需要在一个终端中运行,其中已经将C:\Program Files (x86)\GnuWin32添加到了PATH中。你还可以受益于安装'which',然后可以使用which sed进行检查。

which 也不是标准的;不过,Windows 已经有了基本相同功能的 whereis - undefined

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接