- Published at
- Updated at
- Reading time
Let's have a look at Node.js'
$ 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 =');
The constructor of