Windows无法将'sed'识别为内部或外部命令

时间:2019-11-19 21:02:39

标签: node.js npm sed gatsby

我正在使用gatsby mate产品组合,但是最近的本地开发在我运行npm start时显示错误:

'sed' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! gatsby-starter-mate@2.5.1 fix-medium-plugin: `sed -i' ' 's//latest//g' ./node_modules/gatsby-source-medium/gatsby-node.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the gatsby-starter-mate@2.5.1 fix-medium-plugin script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

似乎没有正确转义s //

此处是其指定行的package.json副本:

  "name": "gatsby-starter-mate",
  "version": "2.5.1",
  "description": "Gatsby v2 starter to create a top notch portfolio!",
  "main": "index.js",
  "scripts": {
  "fix-medium-plugin": "sed -i' ' 's/\/latest//g' ./node_modules/gatsby-source-medium/gatsby-node.js",
  "prepare": "npm run fix-medium-plugin && gatsby clean",
   "build": "npm run prepare && gatsby build",
   "develop": "npm run prepare && gatsby develop",
   "start": "npm run develop",
   "serve": "npm run build && gatsby serve -p 9000",
   "lint": "eslint ./src",
   "setup": "node ./bin/setup.js",
   "e2e:open": "cypress open",
   "e2e:ci": "DETERMINISTIC=true start-server-and-test serve http://localhost:9000 'percy exec -- cypress run'"
  },

1 个答案:

答案 0 :(得分:1)

sed是Unix命令。您可能在VSCode的powershell中,仍然可以使用此Gatsby启动器,只需要在unix终端中运行npm start

您可以将cygwin路径安装到gatsby目录中,然后在其中输入npm start,它将成功运行。

我已经使用此 mate 入门程序创建了一个新的gatsby项目,该启动程序遇到了您遇到的相同问题,然后与 mate 的创建者确认没有其他解决方案这次不是通过unix终端运行它。这是link对在2019年10月21日发生的提交给您造成此问题的确认,您将在其中找到EmaSuriano解决您的问题的方法:)