Unterminated template literal, if first line ends slashed

  • Version: 6.11.3 & 6.10.3
  • Platform: Darwin Kernel Version 16.5.0

I have a small script that templatizes a docker RUN command.

const fileContent = `RUN \\
  cd /tmp && \\
  curl -o ./Python-${version}.tgz https://www.python.org/ftp/python/${version}/Python-${version}.tgz && \\
  tar -xzf ./Python-${version}.tgz && \\
  cd ./Python-${version} && \\
  ./configure && \\
  make && \\
  make install && \\
  cd /tmp && \\
  rm -rf ./Python-${version};
`;

This fails giving:

onst fileContent = `RUN \\
const fileContent = `RUN \\
                    ^^^^^^^

SyntaxError: Unterminated template literal

If I change it to the following, it works:

const fileContent = `#comment

RUN \\
  cd /tmp && \\
  curl -o ./Python-${version}.tgz https://www.python.org/ftp/python/${version}/Python-${version}.tgz && \\
  tar -xzf ./Python-${version}.tgz && \\
  cd ./Python-${version} && \\
  ./configure && \\
  make && \\
  make install && \\
  cd /tmp && \\
  rm -rf ./Python-${version};
`;

Using NVM and switching to 8.6.0 does resolve the issue.