Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Express.js + lint gives mistake

https://www.youtube.com/watch?v=Fa4cRMaTDUI I am watching this lesson and trying to recreate everything author does. At 19:00 he sets vue.js-express.js project. He creates folder called 'server'. In 'server/' he runs 'npm init -f'. Then 'npm install --save nodemon eslint', then he inits eslint. Then in package.json file he writes:

"scripts": {
    "start": "nodemon src/app.js --exec 'npm run lint && node'",
    "lint": "eslint **/*.js"
}

Then in folder 'server' he creates folder 'src'. In 'src' he creates 'app.js'. And in 'app.js; there is a simple console.log('hello'). Then he runs 'npm start'. 'Hello' is printed in terminal, nodemon and eslint works just fine. Then he types 'npm install --save express'. Thats where my problem begins. After installing express.js i type 'npm start' and i get this error in terminal:

Oops! Something went wrong! :(

ESLint: 5.0.0.
No files matching the pattern "node_modules/ipaddr.js" were found.
Please check for typing mistakes in the pattern.

npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] lint: `eslint **/*.js`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the [email protected] 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!     /home/r/.npm/_logs/2018-06-25T10_32_02_027Z-debug.log
[nodemon] process failed, unhandled exit code (2)
[nodemon] Error
at Bus.utils.bus.on (/home/r/projects/tab-tracker/server/node_modules    /nodemon/lib/nodemon.js:148:25)
    at Bus.emit (events.js:164:20)
at ChildProcess.<anonymous> (/home/r/projects/tab-tracker/server/node_modules/nodemon/lib/monitor/run.js:164:11)
at ChildProcess.emit (events.js:159:13)
at Process.ChildProcess._handle.onexit (internal/child_process.js:209:12)

Why is this happening?

like image 473
neku894 Avatar asked Jun 25 '18 10:06

neku894


People also ask

How can you deal with error handling in Express JS?

The simplest way of handling errors in Express applications is by putting the error handling logic in the individual route handler functions. We can either check for specific error conditions or use a try-catch block for intercepting the error condition before invoking the logic for handling the error.

Is Express JS outdated?

It is unmaintainedExpress has not been updated for years, and its next version has been in alpha for 6 years. People may think it is not updated because the API is stable and does not need change. The reality is: Express does not know how to handle async/await .

Is Express JS good for production?

Express is used by big names like Accenture, IBM, and Uber, which means it's also great in a production environment. If you are similarly using Express in this manner (or even just using Express with a team), it's important to learn how to organize your project structure to increase productivity.


2 Answers

Quote the pattern and it works fine as in previous versions of eslint

"lint": "eslint \"**/*.js\""

Credit goes to https://github.com/eslint/eslint/issues/10599

like image 157
Michael Christopher Avatar answered Oct 12 '22 22:10

Michael Christopher


Replace your code

"start": "nodemon src/app.js --exec 'npm run lint && node'",
"lint": "eslint **/*.js"

for

"start": "nodemon src/app.js --exec 'npm run lint && node'",
"lint": "eslint"
like image 22
Giovanni Aranda Avatar answered Oct 12 '22 22:10

Giovanni Aranda