1

I am using cpx to copy .yml files and typescript to compile .ts files. All of this is then served with an npm script using node as follows:

start: "tsc && cpx \"src/**/*.yml\" dist/src && node ./dist/server.js

This functions without a problem on the production server. The problem arises when I try to run the setup in watch mode during development using tsc-watch as follows:

"start:watch": "cpx \"src/**/*.yml\" dist/src --watch && tsc-watch --onSuccess \"node ./dist/server.js\" --onFailure \"echo Beep! Boop! Compilation Failed!\""

I get the failure message Beep! Boop! Compilation Failed! when I run npm run start:watch which however changes to what I would expect when the compilation was successfully. The app then runs correctly.

Is it possible to use tsc-watch together with another script command in watch mode without getting this confusing behaviour?

Awemo
  • 875
  • 1
  • 12
  • 25
  • Your npm script is not valid JSON. Either; **1.** Delete the double quotes from the path provided to `cpx`, i.e. change `"src/**/*.yml"` to `src/**/*.yml`. **2.** Or escape them, i.e. change `"src/**/*.yml"` to `\"src/**/*.yml\"`. – RobC Jan 14 '19 at 08:47
  • @RobC thanks for the correction. The escaping was somehow removed while pasting from my IDE. – Awemo Jan 14 '19 at 12:33

0 Answers0