无法浏览部署到 Heroku 的 React 应用程序

IT技术 javascript node.js reactjs heroku eslint
2021-05-10 21:27:55

在浏览器中写入https://tictactoesko.herokuapp.com/ 时,我收到以下错误消息:

无法编译 ./src/index.js module构建失败:错误:找不到module“eslint/lib/formatters/stylish”

我的 index.js 看起来像这样 import React from 'react' import ReactDOM from 'react-dom' import './index.css' import Game from './Game'

ReactDOM.render(, document.getElementById('root'))

我的 package.json 看起来像这样

{
  "name": "tic-tac-toe",
  "version": "0.1.0",
  "private": true,
  "eslintConfig": {
    "env": {
      "es6": true
    },
    "parserOptions": {
      "ecmaVersion": 8,
      "sourceType": "module",
      "ecmaFeatures": {
        "jsx": true
      }
    },
    "extends": [
      "standard",
      "react-app",
      "plugin:jsx-a11y/recommended" 
    ],
    "plugins": [
      "jsx-a11y",
      "react"
      ],
    "rules": {
      "no-trailing-spaces": "off",
      "padded-blocks":"off",
      "jsx-a11y/href-no-hash":"off"
   }
  },
  "jest": {
    "testMatch": [
      "**/test/**/*.js?(x)"
    ],
    "collectCoverage": true,
    "coverageDirectory": "coverage",
    "coverageThreshold": {
      "global": {
        "branches": 100,
        "functions": 100,
        "lines": 100,
        "statements": 100
      }
    }
  },
  "dependencies": {
    "chromedriver": "^2.35.0",
    "jest-cli": "^22.3.0",
    "react": "^16.2.0",
    "react-dom": "^16.2.0",
    "react-scripts": "1.1.1",
    "selenium-webdriver": "^4.0.0-alpha.1"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "lint": "./node_modules/.bin/eslint  src/** test/** ",
    "test": "jest",
    "eject": "react-scripts eject",
    "cypress:open": "cypress open"
  },
  "devDependencies": {
    "babel-eslint": "^7.2.3",
    "babel-jest": "^22.2.2",
    "babel-preset-env": "^1.6.1",
    "babel-preset-react": "^6.24.1",
    "cypress": "^2.0.3",
    "enzyme": "^3.3.0",
    "enzyme-adapter-react-16": "^1.1.1",
    "eslint": "^4.18.1",
    "eslint-config-google": "^0.9.1",
    "eslint-config-react-app": "^2.1.0",
    "eslint-config-standard": "^11.0.0",
    "eslint-plugin-flowtype": "^2.46.1",
    "eslint-plugin-import": "^2.9.0",
    "eslint-plugin-jsx-a11y": "^6.0.3",
    "eslint-plugin-node": "^6.0.1",
    "eslint-plugin-promise": "^3.6.0",
    "eslint-plugin-react": "^7.7.0",
    "eslint-plugin-standard": "^3.0.1",
    "jest": "^22.3.0",
    "react-test-renderer": "^16.2.0"
  }
}

这是 travis.yml 语言:node_js node_js: - 节点插件:sonarcloud: before_script: - npm start -- --silent & script: - npm run lint - npm test - sonar-scanner -Dsonar.projectKey=TicTacToe -Dsonar。组织=steinko-github -Dsonar.sources=src,test -Dsonar.host.url= https://sonarcloud.io -Dsonar.login=6472ac35c070752487408fd8c946cca6b536eec2 -Dsonar.javascript.lcov.reportPaths=coverage/lcov. npm bin)/cypress run --record --key a1319fd9-2c6e-4888-8f02-e62f02b5001b deploy: provider: heroku
API_KEY:安全:iHZKdF2ZoiXshgTeDfAR8YjhChchFLMSAxU9i62eB / XGzj6VQ2iV9RS9OnD + dfOJAebk40rtEbyxv9Vx4RXBsWCNVMifg6rMoAiW9Bp3Us8Idw5f2kLKD0Sx6qzNZqdn9TzQT3EU12jLjIgpUse9PfJxisd / HZqmtdYQdJCMGcgOZk4lZJmbpe8tmCcU0tnUPxJnuDPUzkrViAK3pe / T8 / m1mdZAZ4 + 2mAIXuJzsf // JJimdwIE3ZqSoxQjEo9l4QmXcdStrC3iAx + GLgjt2j9Rf0ERnuKYPdfSxPUw8O4 / tJHEyF32E + mUPNxX1PvEyzkP6NtBss / 288W0NPg42rxilEivNeJxWS8fGgUyQx52dHXcBZEdPOsye233WtEHvlIYzDj2Gp + IqD6Q2PhptobqK7XJuyM7xS3QH8Yao / JB2ZYz9PnZzngsfC3cohgxFJ3YjWVmfy87Y / BB5JBVAXARMwg6zvKKt + lHdsVbR3CcHN01S9wG4YgdiAViaIa5vEOUcI7OCGRdYlyJTKau4ENj / DahPxG + L7 + wbrx292kL / 9zgg0fINaByBOg + YSJN / OMQOphNMQZR / gUpf /N1T6uZVogH+ZgzY7XXtSRI3EFl4GgIcHFxoNulvNRmJOR04sK0cyznuwifmLjGiuxGCUeI9MUbSoAiNws7KrK6i9uw= app: tictactoesko

部署日志 feom Heroku 看起来像这样构建依赖项在 11.521 秒内安装最新的节点module (package.json + package-lock) -----> 缓存构建清除以前的节点缓存保存 2 个缓存目录(默认):- node_modules - bower_components (没有缓存) -----> 构建成功!-----> 发现进程类型 Procfile 声明类型 -> (none) buildpack 的默认类型 -> web -----> Compressing... Done: 57.4M -----> Launching... Released v11 https://tictactoesko.herokuapp.com/部署到 Heroku

在浏览器中写入https://tictactoesko.herokuapp.com/ 时,我收到以下错误消息:

无法编译 ./src/index.js module构建失败:错误:找不到module 'eslint/lib/formatters/stylish' 我该如何纠正这个错误?

1个回答

eslint手动安装,这可能会破坏事情。您应该卸载它并仅编辑您的.eslintrc文件。在这个 Github问题中查看@gaearon 的评论

但是如果你想直接控制和自定义一切。我会弹出项目:npm run eject查看Create React App的指南