Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Typescript TS5042 Build: Option 'project' cannot be mixed with source files on a command line

Tags:

I am receiving the following error across all typescript projects that I am trying run.

TS5042  Build: Option 'project' cannot be mixed with source files on a command line.

I have downloaded a free Typescript Angular2 template, ran it and this error immediately pops up.

Has it got something to do with my global typescript installation?

like image 429
user1781272 Avatar asked Mar 05 '16 10:03

user1781272


3 Answers

The tsc command can be run in two ways:

  1. With a project parameter, which points to the directory that contains a tsconfig.json. For example: tsc --project ./app. The location of the tsconfig.json determines the set of files that should be included in the compilation. See here for more about the tsconfig.json: http://www.typescriptlang.org/docs/handbook/tsconfig-json.html
  2. With a list of files as the default parameter. For example: tsc MyFile1.ts MyFile2.ts MyFile3.ts.

These two options are incompatible with each other because they both attempt to define which files should be compiled.

What is the command you are using to compile your project? Or are you using an IDE that runs the build for you?

Here's the reference for the tsc compiler options.

like image 136
Nathan Friend Avatar answered Oct 24 '22 10:10

Nathan Friend


i was getting same error but when removed every space in my folders name as shown in path from tsc compiler it now successfully builds.See also this GitHub issue.

like image 36
Rahul Singh Bhadhoriya Avatar answered Oct 24 '22 09:10

Rahul Singh Bhadhoriya


I have found a fix that works for me. I have more than one version of Visualstudio at c:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\

Open v15.0 and copy the Typescript folder to the v14.0 folder.

like image 38
user1781272 Avatar answered Oct 24 '22 09:10

user1781272