- Version: 7.8.0 (although this has existed since the
--check flag was introduced in 5.0.0)
- Platform: macOS
- Subsystem: cli
When loading a module, Node finds the end of a shebang comment by searching for a \r or \n character.
When using the --check flag, Node finds the end of a shebang comment by searching for a character that is not matched by . in a regex.
The characters \u2028 and \u2029 are considered linebreaks in JS, so they aren't matched by . in a regex. As a result, a file with \u2028 or \u2029 in the shebang will load successfully as a module, but will cause an error when parsed with the --check flag.
Example file (contains \u2028 after bin):
#!/usr/bin
/env node
console.log("foo")
The same thing applies when piping code from stdin.