Ошибка: не удалось загрузить импорт плагина: не удается найти модуль 'eslint-plugin-import' при развертывании приложения create-реагировать - PullRequest
0 голосов
/ 13 февраля 2019

Я новичок в создании-реакции-приложения.Я только что сделал быструю настройку с помощью redux и react-router-dom, которые прекрасно собираются на моем компьютере с использованием yarn build, но при нажатии на Scalingo или Heroku сборка завершается с ошибкой:

 ./src/index.jsx
       Error: Failed to load plugin import: Cannot find module 'eslint-plugin-import'
       Referenced from:
       at Array.forEach (<anonymous>)
       at Array.reduceRight (<anonymous>)

Iничего не сделал для настройки развертывания, просто подтолкнул к производству.

Вот полный журнал развертывания:

Enumerating objects: 74, done.
Counting objects: 100% (74/74), done.
Delta compression using up to 4 threads
Compressing objects: 100% (68/68), done.
Writing objects: 100% (74/74), 185.95 KiB | 4.77 MiB/s, done.
Total 74 (delta 20), reused 15 (delta 0)
 <-- Start deployment of xxx-app-staging -->
       Fetching source code
-----> Creating runtime environment

       NPM_CONFIG_LOGLEVEL=error
       NPM_CONFIG_PRODUCTION=true
       NODE_VERBOSE=false
       NODE_ENV=production
       NODE_MODULES_CACHE=true
-----> Installing binaries
       engines.node (package.json):  unspecified
       engines.npm (package.json):   unspecified (use default)
       engines.yarn (package.json):  unspecified (use default)

       Resolving node version 8.x...
       Downloading and installing node 8.15.0...
       Using default npm version: 6.4.1
       Resolving yarn version 1.x...
       Downloading and installing yarn (1.14.0)...
       Installed yarn 1.14.0
-----> Restoring cache
       Skipping cache restore (not-found)
-----> Building dependencies
       Installing node modules (yarn.lock)
       yarn install v1.14.0
       [1/4] Resolving packages...
       [2/4] Fetching packages...
       info fsevents@1.2.4: The platform "linux" is incompatible with this module.
       info "fsevents@1.2.4" is an optional dependency and failed compatibility check. Excluding it from installation.
       info fsevents@1.2.7: The platform "linux" is incompatible with this module.
       info "fsevents@1.2.7" is an optional dependency and failed compatibility check. Excluding it from installation.
       [3/4] Linking dependencies...
       warning " > eslint-plugin-react@7.12.4" has unmet peer dependency "eslint@^3.0.0 || ^4.0.0 || ^5.0.0".
       warning "react-scripts > pnp-webpack-plugin > ts-pnp@1.0.0" has unmet peer dependency "typescript@*".
       warning " > eslint-config-airbnb@17.1.0" has unmet peer dependency "eslint@^4.19.1 || ^5.3.0".
       warning "eslint-config-airbnb > eslint-config-airbnb-base@13.1.0" has unmet peer dependency "eslint@^4.19.1 || ^5.3.0".
       warning " > eslint-plugin-import@2.16.0" has unmet peer dependency "eslint@2.x - 5.x".
       warning " > eslint-plugin-jsx-a11y@6.2.1" has unmet peer dependency "eslint@^3 || ^4 || ^5".
       [4/4] Building fresh packages...
       Done in 12.22s.
       Running build (yarn)
       yarn run v1.14.0
       $ react-scripts build
       Creating an optimized production build...
       Failed to compile.

       ./src/index.jsx
       Error: Failed to load plugin import: Cannot find module 'eslint-plugin-import'
       Referenced from:
       at Array.forEach (<anonymous>)
       at Array.reduceRight (<anonymous>)


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

       We're sorry this build is failing!

       Some possible problems:

       - A module may be missing from 'dependencies' in package.json
       http://doc.scalingo.com/languages/javascript/nodejs#ensure-youre-tracking-all-your-dependencies

       - This module may be specified in 'devDependencies' instead of 'dependencies'
       http://doc.scalingo.com/languages/javascript/nodejs#install-devdependencies

       Keep coding,
       Scalingo

 !     An error occured during buildpack compilation
 !   Error deploying the application
 !   → Invalid return code from buildpack 

А вот мой package.json:

{
  "name": "xxxx",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@sentry/browser": "^4.5.4",
    "prop-types": "^15.7.1",
    "react": "^16.8.1",
    "react-dom": "^16.8.1",
    "react-redux": "^6.0.0",
    "react-redux-i18n": "^1.9.3",
    "react-router-dom": "^4.3.1",
    "react-scripts": "2.1.5",
    "redux": "^4.0.1",
    "redux-logger": "^3.0.6",
    "redux-promise": "^0.6.0",
    "redux-thunk": "^2.3.0"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": [
    ">0.2%",
    "not dead",
    "not ie <= 11",
    "not op_mini all"
  ],
  "devDependencies": {
    "eslint-config-airbnb": "^17.1.0",
    "eslint-plugin-import": "^2.16.0",
    "eslint-plugin-jsx-a11y": "^6.2.1",
    "eslint-plugin-react": "^7.12.4"
  }
}

Я не могу понять, зачем мне использоватьeslint и его плагинов в моем рабочем коде, и как это исправить.Вы можете помочь?

Ответы [ 4 ]

0 голосов
/ 28 августа 2019

По какой-то причине удаление этого из моего пакета CRA.json работал для меня в VS Code:

"babel": {
    "presets": [
      "react-app"
    ]
  }
0 голосов
/ 22 июня 2019

Переместите все свои Devdependencies в dependencies и удалите Devdependencies

Решил проблему для меня

0 голосов
/ 11 августа 2019

Удаление этой строки из package.json сработало для меня:

"eslintConfig": {
    "extends": "react-app"
}

У меня есть более симпатичные настройки в моем коде Visual Studio.Я думаю, что проблема возникает из-за конфликта конфигурации eslint с более красивым.Есть также еще один вариант, который я не пробовал, который устанавливает eslint-config-prettier.Вот документация по нему: Интеграция с красивыми линтерами

0 голосов
/ 14 февраля 2019

Я удалил все свои ранее добавленные devDependencies и eslint config, и это решило мою проблему.

Философия CRA заключается в автоматическом форматировании кода с использованием Prettier , так что я думаю, это то, что яfor

ОБНОВЛЕНИЕ

Проблема заключалась в добавлении devDependencies, которые не установлены в производстве.Переопределение конфигурации eslint в порядке, но все необходимые пакеты должны быть добавлены к основному dependencies.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...