Occurs when there is an unterminated string literal somewhere. String literals
must be enclosed by single ('
) or double ("
) quotes.
Often, it caused by an attempt to use a string literal over multiple lines:
const str = "Here is some text
that I want to break
across multiple lines.";
Fix: Multiple Lines
If you are trying to break a string across multiple lines, you can use template
literals using the backtick (`
) instead:
const str = `Here is some text
that I want to break
across multiple lines.`;
Or you can use string concatenation:
const str = "Here is some text" +
"that I want to break " +
"across multiple lines.";
Or you can use a backslash (\
) at the end of the line:
const str = "Here is some text \
that I want to break \
across multiple lines.";