TypeScript error TS5014: Unexpected token u in JSON at position 0

后端 未结 6 835
南方客
南方客 2021-01-07 19:11

I am trying to compile a .ts to .js

I have tsconfig.json as below

{
\"compilerOptions\": {
    \"target\": \"es5\",
    \"module\": \"co         


        
6条回答
  •  生来不讨喜
    2021-01-07 19:30

    If you look at the error message carefully, you can see the reason for the failure. The command line that was formed to run tsc is looking at the wrong directory. It was looking at /tsconfig.json/ instead of /. See how tsconfig.json is repeated twice in the error?

    error TS5014: Failed to parse file '/tsconfig.json/tsconfig.json': Unexpected token u in JSON at position 0.

    Running npm install typescript --save-dev worked for me, but I can see how editing the task and specifying the command to look in the right directory for tsconfig.json would solve the problem too.

提交回复
热议问题