0

tengo un error al tratar de inicializar ESLINT en un create-react-app:

  1. Versión de NODE: v10.22.1
  2. Versión de NPM: 6.14.6
  3. Versión de Ubuntu: 18.04 LTS

Pasos realizados:

npx create-react-app appreact
alexis@DESKTOP-G61BOKE:/mnt/c/users/alexisdev$ npx create-react-app appreact
npx: installed 97 in 13.211s

Creating a new React app in /mnt/c/users/alexisdev/appreact.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...


> core-js@2.6.11 postinstall /mnt/c/users/alexisdev/appreact/node_modules/babel-runtime/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"


> core-js@3.6.5 postinstall /mnt/c/users/alexisdev/appreact/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"


> core-js-pure@3.6.5 postinstall /mnt/c/users/alexisdev/appreact/node_modules/core-js-pure
> node -e "try{require('./postinstall')}catch(e){}"

+ react@16.14.0
+ react-dom@16.14.0
+ cra-template@1.0.3
+ react-scripts@3.4.3
added 1596 packages from 745 contributors and audited 1600 packages in 230.031s

72 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities


Initialized a git repository.

Installing template dependencies using npm...
npm WARN tsutils@3.17.1 requires a peer of typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/jest-haste-map/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/watchpack-chokidar2/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.2 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/webpack-dev-server/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

+ @testing-library/jest-dom@4.2.4
+ @testing-library/react@9.5.0
+ @testing-library/user-event@7.2.1
added 36 packages from 56 contributors and audited 1636 packages in 14.953s

72 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

Removing template package using npm...

npm WARN tsutils@3.17.1 requires a peer of typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.2 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/webpack-dev-server/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/jest-haste-map/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/watchpack-chokidar2/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

removed 1 package and audited 1635 packages in 8.016s

72 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

Git commit not created { Error: Command failed: git commit -m "Initialize project using Create React App"
    at checkExecSyncError (child_process.js:629:11)
    at execSync (child_process.js:666:13)
    at tryGitCommit (/mnt/c/users/alexisdev/appreact/node_modules/react-scripts/scripts/init.js:62:5)
    at module.exports (/mnt/c/users/alexisdev/appreact/node_modules/react-scripts/scripts/init.js:334:25)
    at [eval]:3:14
    at Script.runInThisContext (vm.js:122:20)
    at Object.runInThisContext (vm.js:329:38)
    at Object.<anonymous> ([eval]-wrapper:6:22)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at evalScript (internal/bootstrap/node.js:590:27)
  status: 128,
  signal: null,
  output: [ null, null, null ],
  pid: 180,
  stdout: null,
  stderr: null }
Removing .git directory...

Success! Created appreact at /mnt/c/users/alexisdev/appreact
Inside that directory, you can run several commands:

  npm start
    Starts the development server.

  npm run build
    Bundles the app into static files for production.

  npm test
    Starts the test runner.

  npm run eject
    Removes this tool and copies build dependencies, configuration files
    and scripts into the app directory. If you do this, you can’t go back!

We suggest that you begin by typing:

  cd appreact
  npm start

Happy hacking!
npm start

Hasta aquí todo genial levanta la aplicación, el problema viene cuando aplico lo siguiente:

npx eslint --init

Aplico toda la configuración necesaria:

alexis@DESKTOP-G61BOKE:/mnt/c/users/alexisdev/appreact$ npx eslint --init
? How would you like to use ESLint? To check syntax, find problems, and enforce code style
? What type of modules does your project use? JavaScript modules (import/export)
? Which framework does your project use? React
? Does your project use TypeScript? No
? Where does your code run? Browser
? How would you like to define a style for your project? Use a popular style guide
? Which style guide do you want to follow? Airbnb: https://github.com/airbnb/javascript
? What format do you want your config file to be in? JSON
Checking peerDependencies of eslint-config-airbnb@latest
Local ESLint installation not found.
The config that you've selected requires the following dependencies:

eslint-plugin-react@^7.20.0 eslint-config-airbnb@latest eslint@^5.16.0 || ^6.8.0 || ^7.2.0 eslint-plugin-import@^2.21.2 eslint-plugin-jsx-a11y@^6.3.0 eslint-plugin-react-hooks@^4 || ^3 || ^2.3.0 || ^1.7.0
? Would you like to install them now with npm? Yes
Installing eslint-plugin-react@^7.20.0, eslint-config-airbnb@latest, eslint@^5.16.0 || ^6.8.0 || ^7.2.0, eslint-plugin-import@^2.21.2, eslint-plugin-jsx-a11y@^6.3.0, eslint-plugin-react-hooks@^4 || ^3 || ^2.3.0 || ^1.7.0
npm WARN @typescript-eslint/eslint-plugin@2.34.0 requires a peer of eslint@^5.0.0 || ^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @typescript-eslint/parser@2.34.0 requires a peer of eslint@^5.0.0 || ^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-config-react-app@5.2.1 requires a peer of eslint@6.x but none is installed. You must install peer dependencies yourself.
npm WARN eslint-config-react-app@5.2.1 requires a peer of eslint-plugin-react-hooks@1.x || 2.x but none is installed. You must install peer dependencies yourself.
npm WARN eslint-loader@3.0.3 requires a peer of eslint@^5.0.0 || ^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN tsutils@3.17.1 requires a peer of typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.2 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/jest-haste-map/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/watchpack-chokidar2/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/webpack-dev-server/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

+ eslint-plugin-react@7.21.4
+ eslint-config-airbnb@18.2.0
+ eslint-plugin-import@2.22.1
+ eslint-plugin-jsx-a11y@6.3.1
+ eslint@7.11.0
+ eslint-plugin-react-hooks@4.1.2
added 62 packages from 40 contributors, updated 8 packages, moved 2 packages and audited 1697 packages in 38.891s

66 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

Successfully created .eslintrc.json file in /mnt/c/users/alexisdev/appreact
ESLint was installed locally. We recommend using this local copy instead of your globally-installed copy.

Y luego ejecuto al querer levantar la aplicación me da el siguiente error:

npm start
alexis@DESKTOP-G61BOKE:/mnt/c/users/alexisdev/appreact$ npm start

> appreact@0.1.0 start /mnt/c/users/alexisdev/appreact
> react-scripts start


There might be a problem with the project dependency tree.
It is likely not a bug in Create React App, but something you need to fix locally.

The react-scripts package provided by Create React App requires a dependency:

  "eslint": "^6.6.0"

Don't try to install it manually: your package manager does it automatically.
However, a different version of eslint was detected higher up in the tree:

  /mnt/c/users/alexisdev/appreact/node_modules/eslint (version: 7.11.0)

Manually installing incompatible versions is known to cause hard-to-debug issues.

If you would prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That will permanently disable this message but you might encounter other issues.

To fix the dependency tree, try following the steps below in the exact order:

  1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
  2. Delete node_modules in your project folder.
  3. Remove "eslint" from dependencies and/or devDependencies in the package.json file in your project folder.
  4. Run npm install or yarn, depending on the package manager you use.

In most cases, this should be enough to fix the problem.
If this has not helped, there are a few other things you can try:

  5. If you used npm, install yarn (http://yarnpkg.com/) and repeat the above steps with it instead.
     This may help because npm has known issues with package hoisting which may get resolved in future versions.

  6. Check if /mnt/c/users/alexisdev/appreact/node_modules/eslint is outside your project directory.
     For example, you might have accidentally installed something in your home folder.

  7. Try running npm ls eslint in your project folder.
     This will tell you which other package (apart from the expected react-scripts) installed eslint.

If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That would permanently disable this preflight check in case you want to proceed anyway.

P.S. We know this message is long but please read the steps above :-) We hope you find them helpful!

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! appreact@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the appreact@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/alexis/.npm/_logs/2020-10-19T10_05_14_442Z-debug.log

Por favor su ayuda, ya busque dos dias enteros en foros internet paginas y no he podido dar con la solución. Muchas gracias de antemano.

2
  • Cuando ejecutas eslint -v, ¿qué se muestra? Es posible que tienes otra versión a nivel global.
    – milmal
    el 19 oct. 2020 a las 11:07
  • No me figura ningún resultado ` alexis@DESKTOP-G61BOKE:~$ eslint -v Command 'eslint' not found, did you mean: command 'nslint' from deb nslint Try: sudo apt install <deb name> `
    – Alexis
    el 19 oct. 2020 a las 17:20

1 respuesta 1

1

Según este issue abierto desde 2018, create-react-app no soporta diferentes versiones de ESLint si estas no respetan el semver de create-react-app. La que npx instala, por defecto es la última, 7.11.0 actualmente, que no es compatible con ^6.6.0

Para tu caso, por ejemplo, deberías instalar una versión de ESLint dentro del rango ^6.6.0 por ejemplo con npx eslint@^6.6.0 --init, o una mas concreta npx eslint@6.9.0 --init (suponiendo que exista la version 6.9.0)

En el issue mencionan también otra posible solución que es añadir a tu fichero .env lo siguiente: SKIP_PREFLIGHT_CHECK=true

2
  • Gracias por tu respuesta, al crear el proyecto viene por defecto con la ultima versión de Eslint pero a nivel local, con el comando que mencionas es posible realizar un downgrade?
    – Alexis
    el 19 oct. 2020 a las 17:24
  • Según el error que muestras: `The react-scripts package provided by Create React App requires a dependency: "eslint": "^6.6.0"`` Parece que create-react-app no utiliza la última versión de eslint. create-react-app no es especialmente configurable, pero permite sobrescribir su configuración de eslint: create-react-app.dev/docs/setting-up-your-editor/… . Siguiendo esos pasos no necesitarías instalar ninguna otra versión de eslint.
    – Ilsanchez
    el 19 oct. 2020 a las 17:46

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.