繁体   English   中英

/bin/sh: SET: 找不到命令

[英]/bin/sh: SET: command not found

我克隆了一个包含以下package.json的反应项目。 yarn之后, yarn start给了我以下错误。 我试过yarn add react-scripts start ,但还是不行。

我正在使用 MacOS。

有人可以帮忙吗?

$ yarn start
yarn run v1.21.1
$ SET PORT=8000 && react-scripts start
/bin/sh: SET: command not found
error Command failed with exit code 127.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

package.json

{
  "name": "frontend",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@material-ui/core": "^4.9.8",
    "@microsoft/office-js-helpers": "^1.0.2",
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.3.2",
    "@testing-library/user-event": "^7.1.2",
    "@types/react-stripe-elements": "^6.0.4",
    "@uifabric/react-cards": "^0.109.49",
    "axios": "^0.19.2",
    "color": "^3.1.2",
    "cross-storage": "^1.0.0",
    "dva": "^2.4.1",
    "dva-model-creator": "^0.4.3",
    "formik": "^2.1.4",
    "lodash": "^4.17.15",
    "moment": "^2.24.0",
    "monaco-editor": "^0.20.0",
    "node-sass": "^4.13.1",
    "office-ui-fabric-react": "^7.105.4",
    "query-string": "^6.11.1",
    "react": "^16.13.1",
    "react-app-polyfill": "^1.0.6",
    "react-dom": "^16.13.1",
    "react-monaco-editor": "^0.35.0",
    "react-scripts": "3.4.1",
    "react-stripe-elements": "^6.1.1",
    "redux-devtools-extension": "^2.13.8",
    "styled-components": "^5.0.1",    
    "typescript": "^3.8.3",
    "yup": "^0.28.3"
  },
  "scripts": {
    "start": "SET PORT=8000 && react-scripts start",
    "build": "react-scripts --max_old_space_size=8096 build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "@types/color": "^3.0.1",
    "@types/cross-storage": "^0.8.29",
    "@types/jest": "^25.1.4",
    "@types/lodash": "^4.14.149",
    "@types/node": "^13.9.5",
    "@types/query-string": "^6.3.0",
    "@types/react": "^16.9.27",
    "@types/react-dom": "^16.9.5",
    "@types/react-redux": "^7.1.7",
    "@types/styled-components": "^5.0.1",
    "@types/yup": "^0.26.33"
  }
}

在 Posixes 上,最兼容的是"env PORT=8000 react-scripts start"

这就是cross-env环境 package 存在的原因; 它在 Windows 和 Posix 系统上都做了正确的事情。

在 MacOS 上,您不需要SET 将 package.json 的start脚本内容更改为PORT=8000 react-scripts start

更好的是,要支持跨操作系统环境变量设置,您可以使用类似cross-env 的东西。 为此,请将依赖项添加到 cross-env ( yarn install --dev cross-env ),然后将start脚本重写为cross-env PORT=8000 react-scripts start

我认为您正在寻找的是在执行命令之前设置环境变量: PORT=8000 react-scripts start ,因为 Linux/Unix 系统不使用 SET 命令设置环境变量,例如 Windows

如果您在找不到react-scripts命令时遇到问题,请使用以下命令直接引用 package 的本地版本: PORT=8000./node_modules/.bin/react-scripts start

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM