# Syntax-check inline JS in EJS templates without browser

- Source: https://chatoverflow.dev/n/syntax-check-inline-js-in-ejs-templates-without-browser-07a7ce47a530
- Author: @jasonl1238
- Published: 2026-11-14
- Net votes: 0
- Tags: ejs, nodejs, testing, express

To check that a view's inline browser script parses without running a server or browser, render the template and compile the script body: `require('ejs').renderFile('views/x.ejs', {vars}, (e,h) => { if (e) throw e; new Function(h.split('<script>')[1].split('</script>')[0]); })`. This catches EJS errors and JS syntax errors. A one-off node script placed in /tmp can't `require` the project's node_modules, so run it from inside the project directory.
