2017-03-04 72 views
2

我正在嘗試使用Angular2創建和.net核心應用程序。 我不斷收到以下錯誤找不到gulp-tsc src文件夾

/wwwroot/NodeLib/gulp-tsc/src/compiler.ts' not found. 

我找不出我缺少什麼。

tsconfig.json

{ 
    "compileOnSave": true, 
    "compilerOptions": { 
    "target": "es5", 
    "module": "commonjs", 
    "moduleResolution": "node", 
    "sourceMap": true, 
    "emitDecoratorMetadata": true, 
    "experimentalDecorators": true, 
    "removeComments": false, 
    "noImplicitAny": true, 
    "outDir": "../wwwroot/app", 
    "types": [] 
    }, 
    "exclude": [ 
    "node_modules", 
    "wwwroot" 
    ] 
} 

的package.json

{ 
    "name": "angular2withvs2015", 
    "version": "1.0.0", 
    "dependencies": { 
    "@angular/common": "~2.1.1", 
    "@angular/compiler": "~2.1.1", 
    "@angular/core": "~2.1.1", 
    "@angular/forms": "~2.1.1", 
    "@angular/http": "~2.1.1", 
    "@angular/platform-browser": "~2.1.1", 
    "@angular/platform-browser-dynamic": "~2.1.1", 
    "@angular/router": "~3.1.1", 
    "@angular/upgrade": "~2.1.1", 
    "bootstrap": "3.3.7", 
    "core-js": "^2.4.1", 
    "reflect-metadata": "^0.1.8", 
    "rxjs": "5.0.0-beta.12", 
    "systemjs": "0.19.39", 
    "zone.js": "^0.6.25" 
    }, 
    "devDependencies": { 
    "gulp": "3.9.1", 
    "rimraf": "^2.5.4", 
    "gulp-typescript": "^3.1.2", 
    "typescript": "^2.0.7", 
    "gulp-tsc": "^1.2.5", 
    "@types/node": "6.0.40" 
    } 
} 

Gulp.js

LIB,node_modules的內容複製到 /wwwroot文件/ NodeLib:
var ts = require('gulp-typescript'); 

var gulp = require('gulp'), 
rimraf = require('rimraf'); 

gulp.task('clean', function (cb) { 
    return rimraf('./wwwroot/NodeLib/', cb) 
}); 

gulp.task('copy:lib', function() { 
    return gulp.src('node_modules/**/*') 
     .pipe(gulp.dest('./wwwroot/NodeLib/')); 
}); 

gulp.task('copy:systemjs', function() { 
    return gulp.src('Scripts/systemjs.config.js') 
     .pipe(gulp.dest('./wwwroot/')); 
}); 
var tsProject = ts.createProject('Scripts/tsconfig.json', { 
    typescript: require('typescript') 
}); 
gulp.task('ts', function() { 
    var tsResult = gulp.src("Scripts/**/*.ts") // instead of gulp.src(...) 
     .pipe(tsProject()); 

    return tsResult.js.pipe(gulp.dest('./wwwroot')); 
}); 


gulp.task('watch', ['watch.ts']); 
gulp.task('watch.ts', ['ts'], function() { 
    return gulp.watch('Scripts/**/*.ts', ['ts']); 
}); 

gulp.task('default', ['watch']); 

回答

0

的問題是由\ node_modules \一飲而盡-TSC \ tsconfig.json

"files": [ 
    "src/compiler.ts", 
    "src/shellescape.ts", 
    "src/tsc.ts" 
    ] 

當你執行任務,一飲而盡副本造成/

根據我的理解,整個內容不是必需的。在我的情況下,我只想要@angular中的內容。所以,我創建了一個新的任務一飲而盡,

gulp.task('copy:[email protected]', function() { 
    return gulp.src('node_modules/@angular/**/*') 
     .pipe(gulp.dest('./wwwroot/NodeLib/@angular/')); 
}); 

然後我的wwwroot刪除NodeLib文件夾,並執行副本:LIB @角一飲而盡任務。它創建了新的NodeLib文件夾,其中只有@angular文件夾。這解決了Visual Studio編譯錯誤問題。

+0

謝謝讓我看看 – R4nc1d

0

gulp-tsc在1.2 *到1.3之間看起來不太好。*不確定主要貢獻者在那裏嘗試做什麼,但1.3.2對於VS2015還沒有工作。恕我直言,你有兩個選擇:從混帳與一飲而盡-TSC

  1. 工作,並引用src目錄複製到NodeLib /或從那裏取出tsconfig.jason。無論是哪種情況,你肯定會有其他的依賴關係被打破,因爲它們都是乾淨的VS構建。

  2. 您需要將Lagsiri Fernando正確建議的不僅@angular複製到NodeLib,而且還要在systemjs.config.js文件中引用每個包以及您在_Layout.cshtml環​​境標記中引用的內容。