How to solve the npm ERR! Missing script: lint
Learn, how to solve the npm ERR! missing script: “lint” error in your JavaScript projects.
This error occurs due to one of the following reasons:
-
Using the
lintscript without defining it inside thescriptsobject in your package.json file. -
Running the
npm run lintcommand in a different directory. -
Not initialized a
package.jsonfile in your project directory.
Run npm lint
npm ERR! Missing script: "lint"
npm ERR!
npm ERR! To see a list of scripts, run:
npm ERR! npm run
npm ERR! A complete log of this run can be found in:To solve the npm ERR! Missing script:“lint” error, add the lint script to your package.json file and open the terminal in your root project directory before running the npm run lint command.
Here is an example:
"scripts": {
"lint": "eslint --ext=.jsx,.js,.tsx,.ts""
},Here, I added a file extensions for the eslint. So, it scans the following names ends with that extensions.
If you don’t have package.json file in your project directory, you can initialize it by running the
npm init -y command.
npm init -yNow, add the lint script to the package.json file.
"scripts": {
"lint": "eslint --ext=.jsx,.js,.tsx,.ts""
},You can also check here, how to install and configure eslint in your project.


