【问题标题】:error Command failed with exit code 1. with react-native and yarn eslint错误命令失败,退出代码为 1。使用 react-native 和 yarn eslint
【发布时间】:2020-10-25 22:24:18
【问题描述】:

当我运行yarn run lint fileName 时,它会返回

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

我尝试过的是yarn install 和yarn upgrade。 npm install 也完成了。 奇怪的是,ESLint 本身正在工作,因此尽管出现此错误,它仍可以编辑我的文件。 不过,我想解决这个错误。

{
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "eject": "expo eject",
    "lint": "eslint --ext .ts,.tsx,.js,.jsx"
  },
  "dependencies": {
    "@expo/react-native-action-sheet": "^3.8.0",
    "@freakycoder/react-native-header-view": "^0.5.1",
    "@react-native-firebase/app": "^7.3.0",
    "@react-navigation/native": "^5.5.1",
    "base-64": "^0.1.0",
    "eslint-cli": "^1.1.1",
    "expo": "^37.0.12",
    "expo-facebook": "~8.1.0",
    "expo-font": "~8.1.0",
    "expo-google-sign-in": "~8.1.0",
    "expo-image-picker": "~8.1.0",
    "google-auth-library": "^6.0.2",
    "native-base": "^2.13.12",
    "react": "~16.9.0",
    "react-dom": "~16.9.0",
    "react-native": "https://github.com/expo/react-native/archive/sdk-37.0.1.tar.gz",
    "react-native-actionsheet": "^2.4.2",
    "react-native-elements": "^2.0.2",
    "react-native-gesture-handler": "~1.6.0",
    "react-native-image-picker": "^2.3.1",
    "react-native-modal": "^11.5.6",
    "react-native-tableview-simple": "^3.2.0",
    "react-native-vector-icons": "^6.6.0",
    "react-native-web": "~0.11.7",
    "react-navigation": "^4.3.9",
    "react-redux": "^7.2.0",
    "redux": "^4.0.5",
    "redux-thunk": "^2.3.0"
  },
  "devDependencies": {
    "@babel/core": "^7.10.3",
    "babel-eslint": "^10.1.0",
    "babel-preset-expo": "^8.2.3",
    "eslint": "^7.3.1",
    "eslint-config-prettier": "^6.11.0",
    "eslint-plugin-prettier": "^3.1.4",
    "eslint-plugin-react": "^7.20.0",
    "prettier": "2.0.5",
    "react-native-dotenv": "^0.2.0"
  }
}

这是我的 package.json。 我不确定是什么问题。如有任何建议,我将不胜感激。

【问题讨论】:

    标签: reactjs react-native eslint linter


    【解决方案1】:

    这是 eslint 设计的,NPM 和 Yarn 都将错误作为退出代码返回。

    您可以通过添加 --silent 标志来使两者中的退出代码静音。

    npm run lint /file/path --silent
    
    yarn run --silent lint /file/path
    

    【讨论】:

      猜你喜欢
      • 2022-01-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-12
      • 2015-10-12
      • 1970-01-01
      • 2022-01-07
      相关资源
      最近更新 更多