The token '&&' is not a valid statement separator in this version

Solution to fixing The Token '&&' is not a valid statement separator error seen in the Visual Studio Code terminal and Angular CLI.

Last updated on 11/21/2021


I was trying to run a command that would allow me to both build my Angular project and deploy it to firebase hosting in a one line command in VS Code's terminal using the Angular CLI.

Original Command

After running this command

ng build --prod && firebase deploy

I was met with this error message:

At line:1 char:17
+ ng build --prod && firebase deploy
+         ~~
The token '&&' is not a valid statement separator in this version.
  + CategoryInfo     : ParserError: (:) [], ParentContainsErrorRecordException
  + FullyQualifiedErrorId : InvalidEndOfLine

Solution

The solution is to use a | instead of && to separate your commands, for example:

ng build --prod | firebase deploy

I hoped this short blog post helped you fix the '&&' is not a valid statement separator error when building your Angular App using VS Code.