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

前端 未结 7 981
北恋
北恋 2021-02-18 22:23

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          


        
相关标签:
7条回答
  • 2021-02-18 23:01

    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.

    0 讨论(0)
  • 2021-02-18 23:05

    You have to add "terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\cmd.exe" to the visual studio code user settings.

    0 讨论(0)
  • 2021-02-18 23:12

    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.

    0 讨论(0)
  • 2021-02-18 23:13

    If could be of help I have a little update. As explained in the previous issues, after I've seen the problems with 1.8 I tried to uninstall it and reinstall 1.7 to continue to work to my projects, but even the installation was ok I had different problems compiling these asp.net 5 apps. I tried repairing vs, uninstalling and reinstalling 1.7 and 1.8 in any order without any changes. In the end I checked the directory C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\TypeScript and I found that at the end of the uninstall of every version of typescript I have this

    search for this folder and delete At this point I tried to remove this directory completely and retried to uninstall typescript 1.7.6. and now it works fine. I tried doing this cleaning up and installing 1.8 beta, but I continue to have the same problem, but at least now I can work on asp.net 5 projects. I think that the problem rolling back to previous version was unable to overwrite at least the TypeScript.Tasks.dll generating an inconsistent behavior. Could be possibile that to make work nightly builds of 1.8

    and the error TS5042 solve. I hope this help you.

    0 讨论(0)
  • 2021-02-18 23:17

    The solution for me was pretty simple. I looked at the filepath for my project and realized one of the folder names in the file path had a space in it. When I renamed the folder without the space, TSC -p worked just fine. It seems like TSC, when parsing out command line args, splits it at spaces so it saw the part of my filepath name after the space as a file to compile.

    0 讨论(0)
  • 2021-02-18 23:18

    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.

    0 讨论(0)
提交回复
热议问题