簡體   English   中英

錯誤命令失敗,退出代碼為 1。使用 react-native 和 yarn eslint

[英]error Command failed with exit code 1. with react-native and yarn eslint

當我運行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 installyarn 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。 我不確定是什么問題。 我將不勝感激任何建議。

這是 eslint 設計的,NPM 和 Yarn 都將錯誤作為退出代碼返回。

您可以通過添加--silent標志來使兩者中的退出代碼靜音。

npm run lint /file/path --silent

yarn run --silent lint /file/path

可能是存在引發錯誤的 lint 發現。 如果規則設置為error而不是warning ,ESLint 就會這樣做。 有關 npm 中的問題,請參閱https://github.com/eslint/eslint/issues/7933中的討論(紗線可能有同樣的問題)

簡短的版本是您必須:

  • 修復所有 lint 發現
  • 更改規則以引發warning而不是error
  • 強制您的命令以 0 退出(例如 package.json 有"lint": "eslint app/;exit 0"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM