Y
Y
YI2020-10-12 16:14:11
JavaScript
YI, 2020-10-12 16:14:11

Why does the project startup script from package.json fail with an error?

When I try to run the script on windows, I get an error:

Error:

SyntaxError: Unexpected token ' in JSON at position 0


Team:
"ts-node --compiler-options '{\"module\": \"CommonJS\"}' ./server/bootstrap.ts"


How can this be fixed?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Aetae, 2020-10-12
@Aetae

Windows does not consider ' quotes and throws them as part of the parameter.
Escaping to make it work on all OSes is not so easy, and the result is ugly, so it is recommended to simply specify the parameters for overwriting under the key ts-nodein tsconfig.json:

{
  "ts-node": {
    "compilerOptions": {
      "module": "CommonJS"
    }
  },
  ...
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question