Closed gintsgints closed 8 years ago
As the error message says, you cannot use the same project in multiple compilations that run at the same time. You're using the same project (tsProject
) in the tasks tsc
, tsc-app
, tsc-unit
and tsc-e2e
. The error is shown when two of these tasks are running at the same time. You should create multiple projects for these tasks. The reason is that a project handles incremental compilation, and incremental compilation requires data from the previous compilation and when the previous compilation is not finished that obviously doesn't work.
You could also compile all sources in a single compilation. In most cases, it isn't worth to split the project into several compilations as a single compilation would be faster.
Also, this isn't only happening on Windows, but also on other platforms.
Thank you for explanation. Sounds like problem with angular2-starter.
This was not only happening on windows, also on Linux. I am on Ubuntu 16.04 and I was experiencing this due to my watch tasks that sometimes occur in quick succession. For example, if I modify and save two files at the same time, this triggers two calls to the watch function which starts to execute each rebuild at once. The result is that pipe line gets congested when it reaches the compilation stage and the first compilation throws the error.
The solution I settled on is a wrapper queue around the project. https://gist.github.com/smac89/49f3b076cd987e0875ba9bfb3fe81ef9
const ts = require('gulp-typescript'); const tsProject = () => ts.createProject('tsconfig.json')();
return gulp .src(['*/[!.d].ts'], { cwd: Paths.src }) .pipe( alias({ paths: { '@': path.resolve(__dirname, '../src'), }, }) ) .pipe(tsProject()) .js.pipe(gulp.dest(Paths.dest),);
Expected behavior: gulp task finishes.
Actual behavior: while compile I get message: angular2-starter\node_modules\gulp-typescript\release\main.js:71 throw new Error('gulp-typescript: A project cannot be used in two compilations at the same time. Create multiple projects with createProject instead.'); ^
Error: gulp-typescript: A project cannot be used in two compilations at the same time. Create multiple projects with createProject instead.
Your gulpfile:
Include your gulpfile, or only the related task (with
ts.createProject
).tsconfig.json
Include your tsconfig, if related to this issue.
Code
Include your TypeScript code, if necessary.