- Published at
- Updated at
- Reading time
That's news to me! Let's have a look.
$ node --check some.js $ node --check some-invalid.js /Users/stefanjudis/test.js:3 }); ^ SyntaxError: Unexpected token } at checkScriptSyntax (bootstrap_node.js:457:5) at startup (bootstrap_node.js:153:11) at bootstrap_node.js:575:3
The documentation of the
check parameter states the following:
Check the script's syntax without executing it. Exits with an error code if script is invalid.
While looking into the
--check option, I also learned about the
vm module. The
const vm = require('vm'); const script = new vm.Script('var a ='); // evalmachine.<anonymous>:1 // var a = // // SyntaxError: Unexpected end of input // at new Script (node:vm:100:7)
The constructor of
--check and the
Yes? Cool! You might want to check out Web Weekly for more quick learnings. The last edition went out 15 days ago.