Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
70
rated 0 times [  71] [ 1]  / answers: 1 / hits: 20478  / 7 Years ago, mon, august 21, 2017, 12:00:00

I am trying to compile a .ts to .js


I have tsconfig.json as below


{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"sourceMap": true,
"outFile": "build/test.js"
},
"exclude": [
"node_modules"
]
}

below is my package.json


{
"name": "test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo "Error: no test specified" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"tsc": "^1.20150623.0",
"typescript": "^2.4.2"
}
}

and the auto generated tasks.json looks like below


{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"type": "typescript",
"tsconfig": "tsconfig.json",
"problemMatcher": [
"$tsc"
],
"group": {
"kind": "build",
"isDefault": true
}
}]
}

When I try to run the build task, I am getting the below error


Executing task: <myprojloc>node_modules.bintsc.cmd  -p "<myprojloc>tsconfig.json" <

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

Terminal will be reused by tasks, press any key to close it.

What I am doing wrong? Please, note I have added the versions in package.json


More From » json

 Answers
46

After trying something from this link, I re-write the tasks.json as below and it now worked. Seems the command has some problem previously


{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"taskName": "compile",
"type": "shell",
"command": "tsc -p tsconfig.json",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": []
}
]
}

[#56701] Thursday, August 17, 2017, 7 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
janjadonb

Total Points: 4
Total Questions: 114
Total Answers: 118

Location: Mali
Member since Fri, Dec 3, 2021
3 Years ago
;