question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error when running eslint manually for default template project

See original GitHub issue

Describe the bug

With a new project using the default template created via

npx create-react-app test-project

running eslint manually via script like

"scripts": {
  ...
  "lint": "eslint './{src,test}/**/*.js'"
}

throws the following error

davidlukerice$ npm run lint

> test-app@0.1.0 lint [...]]/test-app
> eslint './{src,test}/**/*.js'

Error: Failed to load parser '@typescript-eslint/parser' declared in 'package.json » eslint-config-react-app#overrides[0]': Cannot find module 'typescript'
Require stack:
- [...]]/test-app/node_modules/@typescript-eslint/typescript-estree/dist/parser.js
- [...]]/test-app/node_modules/@typescript-eslint/parser/dist/parser.js
- [...]]/test-app/node_modules/eslint/lib/cli-engine/config-array-factory.js
- [...]]/test-app/node_modules/eslint/lib/cli-engine/cascading-config-array-factory.js
- [...]]/test-app/node_modules/eslint/lib/cli-engine/cli-engine.js
- [...]]/test-app/node_modules/eslint/lib/cli-engine/index.js
- [...]]/test-app/node_modules/eslint/lib/cli.js
- [...]]/test-app/node_modules/eslint/bin/eslint.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:794:15)
    at Function.Module._load (internal/modules/cjs/loader.js:687:27)
    at Module.require (internal/modules/cjs/loader.js:849:19)
    at require ([...]]/test-app/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
    at Object.<anonymous> ([...]]/test-app/node_modules/@typescript-eslint/typescript-estree/dist/parser.js:17:25)
    at Module._compile ([...]]/test-app/node_modules/v8-compile-cache/v8-compile-cache.js:194:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
    at Module.load (internal/modules/cjs/loader.js:812:32)
    at Function.Module._load (internal/modules/cjs/loader.js:724:14)
    at Module.require (internal/modules/cjs/loader.js:849:19)
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! test-app@0.1.0 lint: `eslint './{src,test}/**/*.js'`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the test-app@0.1.0 lint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Environment

davidlukerice$ npx create-react-app --info

Environment: OS: macOS 10.15.2 Node: 12.13.0 Yarn: 1.6.0 npm: 6.13.3 Watchman: 4.9.0 Xcode: Xcode 11.3 Build version 11C29 Android Studio: Not Found

Packages: (wanted => installed) react: ^16.12.0 => 16.12.0 react-dom: ^16.12.0 => 16.12.0 react-scripts: 3.3.0 => 3.3.0

Steps to reproduce

  1. Create a new application
  2. Add in "lint": "eslint './{src,test}/**/*.js'" command to package.json
  3. Run the command with npm run lint
  4. See the error

Expected behavior

It should lint fine and not throw an error about a typescript module

Actual behavior

Throws an error.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
davidlukericecommented, Jan 16, 2020

I wouldn’t think I’d need to install typescript for a non typescript app.

0reactions
stale[bot]commented, Feb 20, 2020

This issue has been automatically closed because it has not had any recent activity. If you have a question or comment, please open a new issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

vue.js - Got a delete ESlint/Prettier when I create a template
You can either fix that one manually or run a format via ESlint or directly via Prettier to fix it (depends of the...
Read more >
Configuration Files - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
ESLint | IntelliJ IDEA Documentation - JetBrains
To configure ESLint automatically in the current project, open the Settings/Preferences dialog ( Ctrl+Alt+S ), go to Languages & Frameworks | ...
Read more >
Static Application Security Testing (SAST) - GitLab Docs
The GitLab-managed SAST CI/CD template controls which analyzer jobs run and how they're configured. While using the template, you might experience a job...
Read more >
Setup ESLINT and PRETTIER in React app
If you are using jest then you will find that eslint is giving us an error that test or expect is not defined...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found