Eslint npm error

Tell us about your environment Windows_NT 10.0.14393 ESLint is installed as devDependency ESLint Version: v3.13.1 Node Version: v6.9.1 npm Version: v3.10.8 What parser (default, Babel-ESLint, etc.)...

Tell us about your environment
Windows_NT 10.0.14393
ESLint is installed as devDependency

  • ESLint Version: v3.13.1
  • Node Version: v6.9.1
  • npm Version: v3.10.8

What parser (default, Babel-ESLint, etc.) are you using?
Default

Please show your full configuration:
Dead simple .eslintrc.js in the root folder:

module.exports = {
  root: true,
  parserOptions: {
    ecmaVersion: 2017,
    sourceType: 'script',
  },
  rules: {
    'no-unused-vars': 2,
    'no-console': 1
  }
}

What did you do? Please include the actual source code causing the issue.
Dead simple test file in the root folder to emit both error and warning.

const a = console.log('');

What did you expect to happen?
I should see standard ESLint output (lint error, warning, etc.)

What actually happened? Please include the actual, raw output from ESLint.

  1. When I run eslint directly from CL with node_modules.bineslint tst.js I get expected output:
λ node_modules.bineslint tst.js

C:OpenServerdomainsEXAMPLESwebpack-react-redux-startertst.js
  1:9   error    'a' is assigned a value but never used  no-unused-vars
  1:13  warning  Unexpected console statement            no-console

✖ 2 problems (1 error, 1 warning)
  1. But when I run simple npm script…
"scripts": {
    "lint": "eslint tst.js"
}

… I get standard ESLint at first and then npm error:

λ npm run lint

> webpack-react-redux-starter@0.1.0 lint C:OpenServerdomainsEXAMPLESwebpack-react-redux-starter
> eslint tst.js


C:OpenServerdomainsEXAMPLESwebpack-react-redux-startertst.js
  1:9   error    'a' is assigned a value but never used  no-unused-vars
  1:13  warning  Unexpected console statement            no-console

✖ 2 problems (1 error, 1 warning)


npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "run" "lint"
npm ERR! node v6.9.1
npm ERR! npm  v3.10.8
npm ERR! code ELIFECYCLE
npm ERR! webpack-react-redux-starter@0.1.0 lint: `eslint tst.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the webpack-react-redux-starter@0.1.0 lint script 'eslint tst.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the webpack-react-redux-starter package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     eslint tst.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs webpack-react-redux-starter
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls webpack-react-redux-starter
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:OpenServerdomainsEXAMPLESwebpack-react-redux-starternpm-debug.log

Output in debug mode with "lint": "eslint tst.js --debug":

λ npm run lint

> webpack-react-redux-starter@0.1.0 lint C:OpenServerdomainsEXAMPLESwebpack-react-redux-starter
> eslint tst.js --debug

  eslint:cli Running on files +0ms
  eslint:glob-util Creating list of files to process. +31ms
  eslint:ignored-paths Looking for ignore file in C:OpenServerdomainsEXAMPLESwebpack-react-redux-starter +0ms
  eslint:ignored-paths Could not find ignore file in cwd +0ms
  eslint:cli-engine Processing C:OpenServerdomainsEXAMPLESwebpack-react-redux-startertst.js +0ms
  eslint:cli-engine Linting C:OpenServerdomainsEXAMPLESwebpack-react-redux-startertst.js +0ms
  eslint:config Constructing config for C:OpenServerdomainsEXAMPLESwebpack-react-redux-startertst.js +0ms
  eslint:config Using .eslintrc and package.json files +0ms
  eslint:config Loading C:OpenServerdomainsEXAMPLESwebpack-react-redux-starter.eslintrc.js +0ms
  eslint:config-file Loading JS config file: C:OpenServerdomainsEXAMPLESwebpack-react-redux-starter.eslintrc.js +0ms
  eslint:config Using C:OpenServerdomainsEXAMPLESwebpack-react-redux-starter.eslintrc.js +16ms
  eslint:config Merging command line environment settings +0ms
  eslint:config-ops Apply environment settings to config +0ms
  eslint:cli-engine Linting complete in: 54ms +38ms

C:OpenServerdomainsEXAMPLESwebpack-react-redux-startertst.js
  1:7   error    'a' is assigned a value but never used  no-unused-vars
  1:11  warning  Unexpected console statement            no-console

✖ 2 problems (1 error, 1 warning)


npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "run" "lint"
npm ERR! node v6.9.1
npm ERR! npm  v3.10.8
npm ERR! code ELIFECYCLE
npm ERR! webpack-react-redux-starter@0.1.0 lint: `eslint tst.js --debug`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the webpack-react-redux-starter@0.1.0 lint script 'eslint tst.js --debug'.npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the webpack-react-redux-starter package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     eslint tst.js --debug
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs webpack-react-redux-starter
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls webpack-react-redux-starter
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:OpenServerdomainsEXAMPLESwebpack-react-redux-starternpm-debug.log
  1. If I change my tst.js code so it triggers only lint warning I get expected output (no npm error):
λ npm run lint

> webpack-react-redux-starter@0.1.0 lint C:OpenServerdomainsEXAMPLESwebpack-react-redux-starter
> eslint tst.js


C:OpenServerdomainsEXAMPLESwebpack-react-redux-startertst.js
  1:1  warning  Unexpected console statement  no-console

✖ 1 problem (0 errors, 1 warning)

It’s not a big problem, when I just want to lint some files.
But it becomes a problem when I chain my lint task with other tasks, cause all subsequent tasks don’t run after error occurs.

P.S. There’s closed issue #7402 related to the same problem. I wrote there too. But since get no responce file a new one.

ESLint — это инструмент, помогающий анализировать написанный на JavaScript код, находить синтаксические ошибки и автоматически их исправлять, писать аккуратный код в едином стиле по определённым правилам.

ESLint в терминале

Если у вас пока нет ESLint, его нужно установить из npm.

Давайте испытаем ESLint в действии. Попробуем написать простую функцию для вывода суммы двух чисел и с помощью ESLint проверить правильность написанного кода. Для это в терминале выполним команду

npm run lint

ESLint показывает, что нашёл 6 ошибок в файле main.js. Цифры слева говорят на какой строке, на каком символе, была найдена ошибка. Дальше в строке идёт описание ошибки. Например:

Пример описания ошибки

Текст 5 errors and 0 warnings potentially fixable with the `--fix` option после списка ошибок говорит о том, что пять из шести найденных ошибок ESLint сможет исправить автоматически.

Обратите внимание, что требования, по которым ESLint проверяет код, на каждом проекте могут быть свои, всё зависит от правил, принятых в команде. Например, в команде может быть принято использование двойных кавычек, в таком случае ESLint не будет ругаться на двойные кавычки, а вот при использовании одинарных возникнет ошибка. Такие правила описываются в специальном файле .eslintrc.

Исправление ошибок

Для исправления ошибок у ESLint есть опция fix. Чтобы воспользоваться этой опцией, выполним в терминале команду

npm run lint -- --fix

Ключ --fix говорит о том, что мы хотим исправить ошибки автоматически, а два подчёркивания -- перед ключом помогают понять терминалу, что ключ относится не к команде npm run lint , а к тому, что за ней скрывается — к eslint.

ESLint исправил 5 ошибок: поправил пробелы, заменил кавычки на одинарные, удалил ненужную точку с запятой — теперь код выглядит чище. Осталось вызвать функцию, чтобы исправить последнюю ошибку. Здесь ESLint нам не поможет.

Описание ошибки

ESLint в редакторе

А что, если нам хочется сразу, в момент написания кода, знать, какие ошибки мы совершаем, и исправлять их на лету? Для этого в редактор можно установить расширение для ESLint, которое будет подсвечивать найденную ошибку прямо в файле, а при наведении подсказывать, в чём именно ошибка.

Установка расширения для ESLint в VS Code

Расширение для ESLint в VS Code может попросить подтвердить его запуск, если пакет eslint установлен локально (наш случай). Когда расширение спросит, откуда брать пакет eslint, нужно нажать «Allow», чтобы разрешить использовать eslint в текущем проекте.

Установка расширения для ESLint в VS Code

С помощью расширения для ESLint в редакторе можно автоматически исправить ошибки. Для этого нужно навести на подсвеченную ошибку, нажать кнопку Quick fix во всплывающем окошке и выбрать один из предложенных вариантов. Например, можно исправить только конкретную ошибку, а можно и все доступные разом. Если ошибка не может быть автоматически исправлена, вместо кнопки Quick fix появится текст No quick fixes available или будут предложены альтернативные варианты решения.

Установка расширения для ESLint в Atom

В Atom тоже требуется специальное расширение linter-eslint для работы ESLint. Чтобы в Atom установить расширение, нужно перейти в раздел настроек «Install Packages». Открыть его можно из окна команд (сочетание клавиш Ctrl + Shift + P на Windows и Command + Shift + P на macOS), введя в поиске «Install Packages».

Также нужный раздел настроек можно открыть через меню: Edit → Preferences → Install — на Windows, Atom → Preferences → Install — в macOS.

Установка расширения для ESLint в Atom

Далее ищем нужное расширение и устанавливаем его:

Ищем нужное расширение и устанавливаем его

После установки расширения может появиться всплывающее окно с предложением установить нужные зависимости, то есть другие расширения, с помощью которых работает linter-eslint. Для правильной работы линтера нужно установить все предложенные зависимости.

Устанавливаем все предложенные зависимости

Теперь можно приступить к исправлению ошибок, исправить большинство ошибок можно автоматически, наведя на ошибку и нажав «Fix» или снова использовать окно команд, где выполнить Linter Eslint: Fix File.

Включение поддержки ESLint в WebStorm

В WebStorm не нужно устанавливать отдельное расширение, ESLint работает в этом редакторе «из коробки», достаточно только включить поддержку ESLint. Откройте окно Preferences с настройками, перейдите на вкладку ESLint (Languages and Frameworks → JavaScript → Code Quality Tools → ESLint) и выберете автоматическую конфигурацию ESLint — Automatic ESLint configuration. При автоматической конфигурации ESLint всегда будет искать в директории проекта файл .eslintrc с правилами оформления кода и ориентироваться на него.

Исправляются ошибки так же просто, достаточно нажать правой кнопкой мыши в файле с ошибками и выбрать из списка «Fix ESLint problems».

Дополнительные материалы:

  • 34 инструмента для веб-разработчика на каждый день
  • Обзор Chrome DevTools. Решаем основные задачи разработчика
  • HTML-шаблонизаторы
  • Как проверить валидность HTML-разметки

Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Peter Mingione

Hi All,

I am on video 4 of the «Building Applications with React and Redux» series of videos. I have converted the App.js module to Scoreboard.js and I have installed all the dependencies. When I Try to start the server (npm start) I get an error (see below). It has something to do with ESLint. Thanks in advance for any help you can give me ….

Oops! Something went wrong! :(

ESLint: 7.7.0

No files matching the pattern «./src/*/.{js,» were found.

Please check for typing mistakes in the pattern.

npm ERR! code ELIFECYCLE

npm ERR! errno 2

npm ERR! react-redux-course@1.0.0 lint: eslint ./src/**/*.{js, jsx} --fix

npm ERR! Exit status 2

npm ERR!

npm ERR! Failed at the react-redux-course@1.0.0 lint 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! /Users/petermingione-macbook-home/.npm/_logs/2020-08-24T22_45_07_644Z-debug.log

npm ERR! code ELIFECYCLE

npm ERR! errno 2

npm ERR! react-redux-course@1.0.0 prestart: npm run lint

npm ERR! Exit status 2

npm ERR!

npm ERR! Failed at the react-redux-course@1.0.0 prestart 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! /Users/petermingione-macbook-home/.npm/_logs/2020-08-24T22_45_07_674Z-debug.log

7 Answers

Liam Clarke August 26, 2020 9:18pm

Hi Peter

Can you check that the file path is correct. The relative path is relative to the package.json, not to the working directory.

lint: eslint ./src/*/.{js, jsx}

So the above should have some structure like this:

src/somefolder/some-file.js
package.json
...

Try specifying the extensions separate with the below command in your script

eslint —ext .jsx,.js  src/**/*

Or

eslint —ext .jsx,.js  src/

If that doesn’t work can you paste in the full log so I can see more details as to what’s going wrong /Users/petermingione-macbook-home/.npm/_logs/2020-08-24T22_45_07_674Z-debug.log

Hope this helps!

Peter Mingione

Hi Liam,
I found the log
It is posted below…..

0 info it worked if it ends with ok
1 verbose cli [ ‘/usr/local/Cellar/node/10.9.0/bin/node’,
1 verbose cli ‘/usr/local/bin/npm’,
1 verbose cli ‘start’ ]
2 info using npm@6.14.7
3 info using node@v10.9.0
4 verbose run-script [ ‘prestart’, ‘start’, ‘poststart’ ]
5 info lifecycle react-redux-course@1.0.0~prestart: react-redux-course@1.0.0
6 verbose lifecycle react-redux-course@1.0.0~prestart: unsafe-perm in lifecycle true
7 verbose lifecycle react-redux-course@1.0.0~prestart: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/petermingione-macbook-home/react-projects/learn react course/5. React Redux Course (create-react-app : redux : react-redux)/react-redux/node_modules/.bin:/Users/petermingione-macbook-home/.rvm/gems/ruby-2.5.1/bin:/Users/petermingione-macbook-home/.rvm/gems/ruby-2.5.1@global/bin:/Users/petermingione-macbook-home/.rvm/rubies/ruby-2.5.1/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Users/petermingione-macbook-home/.rvm/bin
8 verbose lifecycle react-redux-course@1.0.0~prestart: CWD: /Users/petermingione-macbook-home/react-projects/learn react course/5. React Redux Course (create-react-app : redux : react-redux)/react-redux
9 silly lifecycle react-redux-course@1.0.0~prestart: Args: [ ‘-c’, ‘npm run lint’ ]
10 silly lifecycle react-redux-course@1.0.0~prestart: Returned: code: 2 signal: null
11 info lifecycle react-redux-course@1.0.0~prestart: Failed to exec prestart script
12 verbose stack Error: react-redux-course@1.0.0 prestart: npm run lint
12 verbose stack Exit status 2
12 verbose stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
12 verbose stack at EventEmitter.emit (events.js:182:13)
12 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
12 verbose stack at ChildProcess.emit (events.js:182:13)
12 verbose stack at maybeClose (internal/child_process.js:961:16)
12 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:250:5)
13 verbose pkgid react-redux-course@1.0.0
14 verbose cwd /Users/petermingione-macbook-home/react-projects/learn react course/5. React Redux Course (create-react-app : redux : react-redux)/react-redux
15 verbose Darwin 19.6.0
16 verbose argv «/usr/local/Cellar/node/10.9.0/bin/node» «/usr/local/bin/npm» «start»
17 verbose node v10.9.0
18 verbose npm v6.14.7
19 error code ELIFECYCLE
20 error errno 2
21 error react-redux-course@1.0.0 prestart: npm run lint
21 error Exit status 2
22 error Failed at the react-redux-course@1.0.0 prestart script.
22 error This is probably not a problem with npm. There is likely additional logging output above.
23 verbose exit [ 2, true ]

Peter Mingione

2nd log file ….

0 info it worked if it ends with ok
1 verbose cli [ ‘/usr/local/Cellar/node/10.9.0/bin/node’,
1 verbose cli ‘/usr/local/bin/npm’,
1 verbose cli ‘run’,
1 verbose cli ‘lint’ ]
2 info using npm@6.14.7
3 info using node@v10.9.0
4 verbose run-script [ ‘prelint’, ‘lint’, ‘postlint’ ]
5 info lifecycle react-redux-course@1.0.0~prelint: react-redux-course@1.0.0
6 info lifecycle react-redux-course@1.0.0~lint: react-redux-course@1.0.0
7 verbose lifecycle react-redux-course@1.0.0~lint: unsafe-perm in lifecycle true
8 verbose lifecycle react-redux-course@1.0.0~lint: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/petermingione-macbook-home/react-projects/learn react course/5. React Redux Course (create-react-app : redux : react-redux)/react-redux/node_modules/.bin:/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/petermingione-macbook-home/react-projects/learn react course/5. React Redux Course (create-react-app : redux : react-redux)/react-redux/node_modules/.bin:/Users/petermingione-macbook-home/.rvm/gems/ruby-2.5.1/bin:/Users/petermingione-macbook-home/.rvm/gems/ruby-2.5.1@global/bin:/Users/petermingione-macbook-home/.rvm/rubies/ruby-2.5.1/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Users/petermingione-macbook-home/.rvm/bin
9 verbose lifecycle react-redux-course@1.0.0~lint: CWD: /Users/petermingione-macbook-home/react-projects/learn react course/5. React Redux Course (create-react-app : redux : react-redux)/react-redux
10 silly lifecycle react-redux-course@1.0.0~lint: Args: [ ‘-c’, ‘eslint ./src//*.{js, jsx} —fix’ ]
11 silly lifecycle react-redux-course@1.0.0~lint: Returned: code: 2 signal: null
12 info lifecycle react-redux-course@1.0.0~lint: Failed to exec lint script
13 verbose stack Error: react-redux-course@1.0.0 lint: `eslint ./src/
/.{js, jsx} —fix
13 verbose stack Exit status 2
13 verbose stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:182:13)
13 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:182:13)
13 verbose stack at maybeClose (internal/child_process.js:961:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:250:5)
14 verbose pkgid react-redux-course@1.0.0
15 verbose cwd /Users/petermingione-macbook-home/react-projects/learn react course/5. React Redux Course (create-react-app : redux : react-redux)/react-redux
16 verbose Darwin 19.6.0
17 verbose argv "/usr/local/Cellar/node/10.9.0/bin/node" "/usr/local/bin/npm" "run" "lint"
18 verbose node v10.9.0
19 verbose npm v6.14.7
20 error code ELIFECYCLE
21 error errno 2
22 error react-redux-course@1.0.0 lint:
eslint ./src/
/.{js, jsx} —fix`
22 error Exit status 2
23 error Failed at the react-redux-course@1.0.0 lint script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 2, true ]

Peter Mingione

0 info it worked if it ends with ok 1 verbose cli [ ‘/usr/local/Cellar/node/10.9.0/bin/node’,

1 verbose cli ‘/usr/local/bin/npm’, 1 verbose cli ‘start’ ]

2 info using npm@6.14.7

3 info using node@v10.9.0

4 verbose run-script [ ‘prestart’, ‘start’, ‘poststart’ ]

5 info lifecycle react-redux-course@1.0.0~prestart: react-redux-course@1.0.0

6 verbose lifecycle react-redux-course@1.0.0~prestart: unsafe-perm in lifecycle true

7 verbose lifecycle react-redux-course@1.0.0~prestart: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/petermingione-macbook-home/react-projects/learn react course/5. React Redux Course (create-react-app : redux : react-redux)/react-redux/node_modules/.bin:/Users/petermingione-macbook-home/.rvm/gems/ruby-2.5.1/bin:/Users/petermingione-macbook-home/.rvm/gems/ruby-2.5.1@global/bin:/Users/petermingione-macbook-home/.rvm/rubies/ruby-2.5.1/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Users/petermingione-macbook-home/.rvm/bin

8 verbose lifecycle react-redux-course@1.0.0~prestart: CWD: /Users/petermingione-macbook-home/react-projects/learn react course/5. React Redux Course (create-react-app : redux : react-redux)/react-redux

9 silly lifecycle react-redux-course@1.0.0~prestart: Args: [ ‘-c’, ‘npm run lint’ ]

10 silly lifecycle react-redux-course@1.0.0~prestart: Returned: code: 2 signal: null

11 info lifecycle react-redux-course@1.0.0~prestart: Failed to exec prestart script

12 verbose stack Error: react-redux-course@1.0.0 prestart: npm run lint

12 verbose stack Exit status 2

12 verbose stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)

12 verbose stack at EventEmitter.emit (events.js:182:13)

12 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)

12 verbose stack at ChildProcess.emit (events.js:182:13)

12 verbose stack at maybeClose (internal/child_process.js:961:16)

12 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:250:5)

13 verbose pkgid react-redux-course@1.0.0

14 verbose cwd /Users/petermingione-macbook-home/react-projects/learn react course/5. React Redux Course (create-react-app : redux : react-redux)/react-redux

15 verbose Darwin 19.6.0

16 verbose argv «/usr/local/Cellar/node/10.9.0/bin/node» «/usr/local/bin/npm» «start»

17 verbose node v10.9.0

18 verbose npm v6.14.7

19 error code ELIFECYCLE

20 error errno 2

21 error react-redux-course@1.0.0 prestart: npm run lint

21 error Exit status 2

22 error Failed at the react-redux-course@1.0.0 prestart script.

22 error This is probably not a problem with npm. There is likely additional logging output above.

23 verbose exit [ 2, true ]

Peter Mingione

0 info it worked if it ends with ok

1 verbose cli [ ‘/usr/local/Cellar/node/10.9.0/bin/node’,

1 verbose cli ‘/usr/local/bin/npm’,

1 verbose cli ‘run’,

1 verbose cli ‘lint’ ]

2 info using npm@6.14.7

3 info using node@v10.9.0

4 verbose run-script [ ‘prelint’, ‘lint’, ‘postlint’ ]

5 info lifecycle react-redux-course@1.0.0~prelint: react-redux-course@1.0.0

6 info lifecycle react-redux-course@1.0.0~lint: react-redux-course@1.0.0

7 verbose lifecycle react-redux-course@1.0.0~lint: unsafe-perm in lifecycle true

8 verbose lifecycle react-redux-course@1.0.0~lint: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/petermingione-macbook-home/react-projects/learn react course/5. React Redux Course (create-react-app : redux : react-redux)/react-redux/node_modules/.bin:/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/petermingione-macbook-home/react-projects/learn react course/5. React Redux Course (create-react-app : redux : react-redux)/react-redux/node_modules/.bin:/Users/petermingione-macbook-home/.rvm/gems/ruby-2.5.1/bin:/Users/petermingione-macbook-home/.rvm/gems/ruby-2.5.1@global/bin:/Users/petermingione-macbook-home/.rvm/rubies/ruby-2.5.1/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Users/petermingione-macbook-home/.rvm/bin

9 verbose lifecycle react-redux-course@1.0.0~lint: CWD: /Users/petermingione-macbook-home/react-projects/learn react course/5. React Redux Course (create-react-app : redux : react-redux)/react-redux

10 silly lifecycle react-redux-course@1.0.0~lint: Args: [ ‘-c’, ‘eslint ./src/*/.{js, jsx} —fix’ ]

11 silly lifecycle react-redux-course@1.0.0~lint: Returned: code: 2 signal: null

12 info lifecycle react-redux-course@1.0.0~lint: Failed to exec lint script

13 verbose stack Error: react-redux-course@1.0.0 lint: eslint ./src/**/*.{js, jsx} --fix

13 verbose stack Exit status 2

13 verbose stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)

13 verbose stack at EventEmitter.emit (events.js:182:13)

13 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)

13 verbose stack at ChildProcess.emit (events.js:182:13)

13 verbose stack at maybeClose (internal/child_process.js:961:16)

13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:250:5)

14 verbose pkgid react-redux-course@1.0.0

15 verbose cwd /Users/petermingione-macbook-home/react-projects/learn react course/5. React Redux Course (create-react-app : redux : react-redux)/react-redux

16 verbose Darwin 19.6.0

17 verbose argv «/usr/local/Cellar/node/10.9.0/bin/node» «/usr/local/bin/npm» «run» «lint»

18 verbose node v10.9.0

19 verbose npm v6.14.7

20 error code ELIFECYCLE

21 error errno 2

22 error react-redux-course@1.0.0 lint: eslint ./src/**/*.{js, jsx} --fix

22 error Exit status 2

23 error Failed at the react-redux-course@1.0.0 lint script.

23 error This is probably not a problem with npm. There is likely additional logging output above.

24 verbose exit [ 2, true ]

Liam Clarke August 27, 2020 7:39am

Hmm could be a dependency or caching issue but I believe its a versioning issue. Could you do the following steps just to be sure:

  1. Clean your node cache

  2. Remove your node_modules folder

  3. Fresh install

  4. Run eslint script by itself

  5. It looks like the error is triggering due to no files being found. Which it should as where you are at in the video, there is no files under src. If you go into your package.json and replace the lint script with the following.
    This is exactly the same as before with the --no-error-on-unmatched-pattern argument that will suppress the errors if nothing is found. Reference

    eslint ./src/**/*.{js, jsx} --fix --no-error-on-unmatched-pattern
    

As for the reasoning. This is due to the difference in versions. In the video, they are using eslint 3.3.1 and you are using 7.7.0. This was introduced in v6.x.

Good Luck!

Peter Mingione

Hi Liam,
Thank you for all of the help. I’ve followed the steps above but the server is still not starting. Here is the log output….

0 info it worked if it ends with ok

1 verbose cli [ ‘/usr/local/Cellar/node/10.9.0/bin/node’,

1 verbose cli ‘/usr/local/bin/npm’,

1 verbose cli ‘start’ ]

2 info using npm@6.14.7

3 info using node@v10.9.0

4 verbose run-script [ ‘prestart’, ‘start’, ‘poststart’ ]

5 info lifecycle react-redux-course@1.0.0~prestart: react-redux-course@1.0.0

6 verbose lifecycle react-redux-course@1.0.0~prestart: unsafe-perm in lifecycle true

7 verbose lifecycle react-redux-course@1.0.0~prestart: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/petermingione-macbook-home/react-projects/learn react course/5. React Redux Course (create-react-app : redux : react-redux)/react-redux-part-one/node_modules/.bin:/Users/petermingione-macbook-home/.rvm/gems/ruby-2.5.1/bin:/Users/petermingione-macbook-home/.rvm/gems/ruby-2.5.1@global/bin:/Users/petermingione-macbook-home/.rvm/rubies/ruby-2.5.1/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Users/petermingione-macbook-home/.rvm/bin

8 verbose lifecycle react-redux-course@1.0.0~prestart: CWD: /Users/petermingione-macbook-home/react-projects/learn react course/5. React Redux Course (create-react-app : redux : react-redux)/react-redux-part-one

9 silly lifecycle react-redux-course@1.0.0~prestart: Args: [ ‘-c’, ‘npm run lint’ ]

10 silly lifecycle react-redux-course@1.0.0~prestart: Returned: code: 0 signal: null

11 info lifecycle react-redux-course@1.0.0~start: react-redux-course@1.0.0

12 verbose lifecycle react-redux-course@1.0.0~start: unsafe-perm in lifecycle true

13 verbose lifecycle react-redux-course@1.0.0~start: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/petermingione-macbook-home/react-projects/learn react course/5. React Redux Course (create-react-app : redux : react-redux)/react-redux-part-one/node_modules/.bin:/Users/petermingione-macbook-home/.rvm/gems/ruby-2.5.1/bin:/Users/petermingione-macbook-home/.rvm/gems/ruby-2.5.1@global/bin:/Users/petermingione-macbook-home/.rvm/rubies/ruby-2.5.1/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Users/petermingione-macbook-home/.rvm/bin

14 verbose lifecycle react-redux-course@1.0.0~start: CWD: /Users/petermingione-macbook-home/react-projects/learn react course/5. React Redux Course (create-react-app : redux : react-redux)/react-redux-part-one

15 silly lifecycle react-redux-course@1.0.0~start: Args: [ ‘-c’, ‘webpack-dev-server —progress —inline —hot’ ]

16 info lifecycle react-redux-course@1.0.0~start: Failed to exec start script

17 verbose stack Error: react-redux-course@1.0.0 start: webpack-dev-server --progress --inline --hot

17 verbose stack spawn ENOENT

17 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:48:18)

17 verbose stack at ChildProcess.emit (events.js:182:13)

17 verbose stack at maybeClose (internal/child_process.js:961:16)

17 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:250:5)

18 verbose pkgid react-redux-course@1.0.0

19 verbose cwd /Users/petermingione-macbook-home/react-projects/learn react course/5. React Redux Course (create-react-app : redux : react-redux)/react-redux-part-one

20 verbose Darwin 19.6.0

21 verbose argv «/usr/local/Cellar/node/10.9.0/bin/node» «/usr/local/bin/npm» «start»

22 verbose node v10.9.0

23 verbose npm v6.14.7

24 error code ELIFECYCLE

25 error syscall spawn

26 error file sh

27 error errno ENOENT

28 error react-redux-course@1.0.0 start: webpack-dev-server --progress --inline --hot

28 error spawn ENOENT

29 error Failed at the react-redux-course@1.0.0 start script.

29 error This is probably not a problem with npm. There is likely additional logging output above.

30 verbose exit [ 1, true ]

Я пытаюсь установить ESLint с помощью npm,

npm install -g eslint

Однако я получаю следующую ошибку:

Deans-Air:~ deangibson$ npm install -g eslint
npm ERR! tar.unpack untar error /Users/deangibson/.npm/eslint/2.4.0/package.tgz
npm ERR! Darwin 15.3.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "eslint"
npm ERR! node v4.2.3
npm ERR! npm  v2.14.7
npm ERR! path /usr/local/lib/node_modules/eslint
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall mkdir

npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/eslint'
npm ERR!     at Error (native)
npm ERR!  { [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/eslint']
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'mkdir',
npm ERR!   path: '/usr/local/lib/node_modules/eslint',
npm ERR!   fstream_type: 'Directory',
npm ERR!   fstream_path: '/usr/local/lib/node_modules/eslint',
npm ERR!   fstream_class: 'DirWriter',
npm ERR!   fstream_stack: 
npm ERR!    [ '/usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:35:25',
npm ERR!      '/usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:47:53',
npm ERR!      'FSReqWrap.oncomplete (fs.js:82:15)' ] }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/deangibson/npm-debug.log

И, честно говоря, я получаю это каждый раз, когда пытаюсь что-то установить с помощью npm. Иногда использование sudo работает, иногда нет … Как я могу исправить это раз и навсегда?

Ответы

Используйте флаги --unsafe-perm=true и --allow-root с npm install, как показано ниже: —

sudo npm install -g eslint --unsafe-perm=true --allow-root

это сработало для меня как шарм.

Эта проблема хорошо задокументирована в документации npm: Исправление разрешений npm .

У вас есть 2 решения:

Вариант 1. Измените каталог по умолчанию npm на скрытый каталог в вашей домашней папке.

mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
export PATH=~/.npm-global/bin:$PATH
source ~/.profile

Вариант 2. Используйте менеджер пакетов, который позаботится об этом за вас

brew install node

Выполнение следующей команды решило проблему для меня при установке моего пакета packages.json:

 sudo npm install --unsafe-perm=true --allow-root

Чтобы установить только пакет, из-за которого возникла проблема:

  sudo npm install -g --unsafe-perm=true --allow-root eslint

sudo npm install -g --unsafe-perm=true eslint

достаточно.

Используйте sudo перед tns, и это работает для меня

Пример:

sudo tns create Tekmo --template tns-template-hello-world

если я использовал sudo, то ошибка не обнаружена, например, при создании postinstall.js

Ошибка: EACCES: в разрешении отказано

Для пользователя MAC предоставьте разрешение на доступ к папке каталога проекта.

  1. Щелкните правой кнопкой мыши папку каталога проекта
  2. Выберите получить информацию
  3. Предоставьте разрешение на доступ — примените к закрытым объектам

Просто была такая же ошибка во время работы

npm install -g @ionic/cli native-run cordova-res

Чтобы исправить, запустите следующее

sudo apt update
sudo apt upgrade -y

Я прочитал уже существующие решения, но подумал, что есть что-то еще, UNSAFE — не безопасное ключевое слово, лол. Выполняя команду с параметром —unsafe-perm = true, я заметил, что она загружает двоичные файлы обновления. Итак, я обновился и попробовал снова.

VSCode is an excellent source code editor, ESLint is the best linter for Javascript. They are great when they work together, but when they don’t, you will find ourself pulling your hair out just to figure out how to get them back together.

This article is a checklist of what you can do if ESLint stopped working with VSCode.

Run npm install?

At first, it seems to be pointless to add this in the list, I know. But I found myself forget to run npm install eslint so many times that I can’t remember, especially if the project is shared among a few people.

Restart VSCode

You’ll never know how many times I fixed the issue just by restarting VSCode, or my computer altogether. In rare times, the TypeScript server may have some internal issues and restarting the machine seems to be the best way to reset things to scratch.

Install ESLint + Plugins + Presets?

Take a look into your eslintrc configuration file and make a list of all plugins and presets. Than make sure, they as well as ESLint itself are in your projects devDependencies.

Make sure ESLint work for correct file extensions

In case you’re using TypeScript, Vue.js or other non-standard JavaScript files, make sure to tell ESLint about your file extensions by using the --ext flag like so --ext .js,.ts,.vue.

You can open VSCode settings.json file and add the following lines to make sure ESLint work with the detected languages. To do that, open Command Palette and find Open Settings (JSON) to open settings.json.

"eslint.validate": [ "vue", "html", "javascript", "typescript", "javascriptreact", "typescriptreact" ]

Code language: JavaScript (javascript)

Also, check your user settings.json file before blindly sticking the same eslint.validate JSON config in each workspace individually.

Check for duplicate .eslintrc files

The default behavior of ESLint is to look for configuration files in higher directories automatically. So in order to avoid confusion and strange errors, make sure you have just a manageable number of .eslintrc in your project

Also, your .eslintrc may be named incorrectly as .eslintrc.js, in that case, simply rename the file does the trick.

When looking for more .eslintrc files, remember, that they might be invisible to your file explorer. Use ls -a or show hidden files in your file explorer so you can carefully inspect files.

Additionally, you can disable ESLint automatic configuration search by adding root option to the .eslintrc in your project root directory:

{ "root": true }

Code language: JSON / JSON with Comments (json)

If you need more information, read Configuration Cascading and Hierarchy.

Alternatively, you can set eslint.workingDirectories to a manageable list of directories, instead of letting ESLint to search for configuration files. Put these lines in your VSCode global settings.json file.

"eslint.workingDirectories": [ "./backend", "./frontend" ],

Code language: JavaScript (javascript)

ESLint runs in terminal but not VSCode

If ESLint is running in the terminal but not inside VSCode, it is probably because the extension is unable to detect both the local and the global node_modules folders.

To verify, press Ctrl+Shift+U in VSCode to open the Output panel after opening a JavaScript file with a known eslint issue. If it shows Failed to load the ESLint library for the document {documentName}.js -or- if the Problems tab shows an error or a warning that refers to eslint, then VSCode is having a problem trying to detect the path.

If yes, then set it manually by configuring the eslint.nodePath in the VSCode settings (settings.json). Give it the full path (for example, like "eslint.nodePath": "C:\Program Files\nodejs",) — using environment variables is currently not supported.
This option has been documented at the ESLint extension page.

Check ESLint log for errors

In VSCode, open the terminal by pressing Ctrl+` keyboard combination.

Select ESLint from the terminal channel dropdown. In here, you would find useful debugging information such as errors, warnings, etc.

select ESLint log in vscode

For example, missing .eslintrc-.json throw this error:

missing .eslintrc-.json

Also, remember to check whether the ESLint extension is enabled globally or not.

check whether the ESLint extension is enabled globally

#npm #eslint

Вопрос:

У меня есть приложение для портфолио Гэтсби, и мне пришлось внести в него некоторые изменения. Затем клонировал его с github и должен был установить зависимости. Когда я запускаю npm install , у меня есть журнал ошибок ниже:

 npm WARN ERESOLVE overriding peer dependency
npm WARN Found: eslint-plugin-flowtype@undefined
npm WARN node_modules/eslint-plugin-flowtype
npm WARN 
npm WARN Could not resolve dependency:
npm WARN peer eslint-plugin-flowtype@"3.x || 4.x" from eslint-config-react-app@5.2.1
npm WARN node_modules/eslint-config-react-app
npm WARN   eslint-config-react-app@"^5.2.1" from gatsby@2.32.13
npm WARN   node_modules/gatsby
npm WARN ERESOLVE overriding peer dependency
npm WARN Found: eslint-plugin-react@undefined
npm WARN node_modules/eslint-plugin-react
npm WARN 
npm WARN Could not resolve dependency:
npm WARN peer eslint-plugin-react@"7.x" from eslint-config-react-app@5.2.1
npm WARN node_modules/eslint-config-react-app
npm WARN   eslint-config-react-app@"^5.2.1" from gatsby@2.32.13
npm WARN   node_modules/gatsby
npm WARN ERESOLVE overriding peer dependency
npm WARN Found: eslint-plugin-react-hooks@undefined
npm WARN node_modules/eslint-plugin-react-hooks
npm WARN 
npm WARN Could not resolve dependency:
npm WARN peer eslint-plugin-react-hooks@"1.x || 2.x" from eslint-config-react-app@5.2.1
npm WARN node_modules/eslint-config-react-app
npm WARN   eslint-config-react-app@"^5.2.1" from gatsby@2.32.13
npm WARN   node_modules/gatsby
npm WARN ERESOLVE overriding peer dependency
npm WARN Found: graphql@undefined
npm WARN node_modules/graphql
npm WARN 
npm WARN Could not resolve dependency:
npm WARN peer graphql@"^14.4.1" from express-graphql@0.9.0
npm WARN node_modules/express-graphql
npm WARN   express-graphql@"^0.9.0" from gatsby@2.32.13
npm WARN   node_modules/gatsby
npm WARN ERESOLVE overriding peer dependency
npm WARN Found: graphql@undefined
npm WARN node_modules/gatsby-source-strapi/node_modules/graphql
npm WARN 
npm WARN Could not resolve dependency:
npm WARN peer graphql@"^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0" from express-graphql@0.6.12
npm WARN node_modules/gatsby-source-strapi/node_modules/express-graphql
npm WARN   express-graphql@"^0.6.6" from gatsby@1.9.279
npm WARN   node_modules/gatsby-source-strapi/node_modules/gatsby
npm WARN ERESOLVE overriding peer dependency
npm WARN Found: graphql@undefined
npm WARN node_modules/gatsby-source-strapi/node_modules/gatsby/node_modules/graphql
npm WARN 
npm WARN Could not resolve dependency:
npm WARN peer graphql@"^0.5.0 || ^0.6.0 || ^0.7.0 || ^0.8.0-b || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0" from graphql-relay@0.5.5
npm WARN node_modules/gatsby-source-strapi/node_modules/gatsby/node_modules/graphql-relay
npm WARN   graphql-relay@"^0.5.1" from gatsby@1.9.279
npm WARN   node_modules/gatsby-source-strapi/node_modules/gatsby
npm ERR! code FETCH_ERROR
npm ERR! errno FETCH_ERROR
npm ERR! invalid json response body at https://registry.npmjs.org/axios reason: Unexpected end of JSON input
 

Я очистил кэш с помощью npm cache clean --force и запустил npm install снова, но у меня все еще та же ошибка….

 npm ERR! code FETCH_ERROR
npm ERR! errno FETCH_ERROR
npm ERR! invalid json response body at https://registry.npmjs.org/axios reason: Unexpected end of JSON input
 

Любая помощь, как я могу решить эту проблему, была бы очень признательна.

файл package.json

 {
  "name": "gatsby-starter-hello-world",
  "private": true,
  "description": "A simplified bare-bones starter for Gatsby",
  "version": "0.1.0",
  "license": "MIT",
  "scripts": {
    "build": "gatsby build",
    "develop": "gatsby develop",
    "format": "prettier --write "**/*.{js,jsx,json,md}"",
    "start": "npm run develop",
    "serve": "gatsby serve",
    "clean": "gatsby clean",
    "test": "echo "Write tests! -> https://gatsby.dev/unit-testing" amp;amp; exit 1"
  },
  "dependencies": {
    "gatsby": "^2.21.0",
    "gatsby-image": "^2.4.0",
    "gatsby-plugin-react-helmet": "^3.3.1",
    "gatsby-plugin-webfonts": "^1.1.3",
    "gatsby-plugin-sharp": "^2.6.0",
    "gatsby-plugin-sitemap": "^2.4.2",
    "gatsby-source-filesystem": "^2.3.0",
    "gatsby-source-strapi": "0.0.12",
    "gatsby-transformer-sharp": "^2.5.0",
    "react": "^16.12.0",
    "react-dom": "^16.12.0",
    "react-helmet": "^6.0.0",
    "react-icons": "^3.10.0",
    "react-markdown": "^4.3.1"
  },
  "devDependencies": {
    "prettier": "2.0.5"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/gatsbyjs/gatsby-starter-hello-world"
  },
  "bugs": {
    "url": "https://github.com/gatsbyjs/gatsby/issues"
  }
}
 

Комментарии:

1. добавьте свой пакет.json здесь

2. Я отредактирую исходный пост и добавлю package.json

Ответ №1:

Это не проблема с вашей стороны. Это не проблема package.json . В ERR URL https://registry.npmjs.org/axios -адресе (последняя строка сообщения об ошибке) дается неверный ответ JSON. Смотрите изображение ниже. Проверка JSON завершается неудачно. Они должны решить эту проблему.

Попробуй бежать

 npm cache clean --force
npm cache verify
yarn
 

Или попробуйте удалить, а затем переустановить.

Редактировать:

Удалите node_modules папку и lock файл. Затем попробуйте запустить yarn

Если вы еще не yarn установили, установите его с помощью

 npm i -g yarn
 

Проверьте установку с помощью

 yarn --version
 

введите описание изображения здесь

Комментарии:

1.Я получаю это npm cache clean --force npm WARN using --force Recommended protections disabled. при запуске Когда я запускаю npm cache verify , я получаю следующие результаты: ` Проверка кэша npm Проверка кэша и сжатие (~/.npm/_cacache) Проверено содержимое: 0 (0 байт) Записей индекса: 0 Завершено за 0,009 с «

2. Он установлен сейчас?

3. он не устанавливался

4. Хорошо, никаких проблем. Найдите его здесь — https://github.com/t-yanick/tazoh-portfolio

5. Одну минуту. Я просто бегу yarn с просто package.json

Понравилась статья? Поделить с друзьями:
  • Esl4550ro ошибка i20
  • Esia1 код ошибки
  • Esia 910313 код ошибки
  • Esia 000001 внутренняя ошибка
  • Esf 45030 electrolux сброс ошибок