Error when running eslint manually for default template project
See original GitHub issueDescribe 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
- Create a new application
- Add in
"lint": "eslint './{src,test}/**/*.js'"
command topackage.json
- Run the command with
npm run lint
- 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:
- Created 4 years ago
- Reactions:2
- Comments:5 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I wouldn’t think I’d need to install typescript for a non typescript app.
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.