Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to compile or check syntax error in Node.js application

I have created a node.js application. I need to compile or do a check whether syntax error occurs before running the node.js service.I need to integrate this in jenkins. Kindly guide me to validate the node.js application

like image 937
user2439278 Avatar asked Oct 30 '25 05:10

user2439278


2 Answers

using eslint package https://www.npmjs.com/package/eslint It's a very common library to check the syntax of any JS/TS framework

like image 166
Mhd Wael Jazmati Avatar answered Oct 31 '25 19:10

Mhd Wael Jazmati


Node.js provides CLI option --check or -c for checking a given file for syntax errors without running it. When working with Linux or MacOS a command like the following one helps with checking all obvious javascript files in a folder for containing basically working code:

find -name "*.js" | xargs node -c
like image 30
Thomas Urban Avatar answered Oct 31 '25 19:10

Thomas Urban