我正在尝试使用Angular2创建和.net核心应用程序。 我一直收到以下错误
/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
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 :(得分:0)
问题是由\ node_modules \ gulp-tsc \ tsconfig.json
引起的"files": [
"src/compiler.ts",
"src/shellescape.ts",
"src/tsc.ts"
]
执行gulp任务 copy:lib 时,node_modules的内容将复制到 / wwwroot / NodeLib /
根据我的理解,不需要全部内容。就我而言,我只想要 @angular 中的内容。所以,我创建了一个新的gulp任务,
gulp.task('copy:lib@angular', function () {
return gulp.src('node_modules/@angular/**/*')
.pipe(gulp.dest('./wwwroot/NodeLib/@angular/'));
});
然后我删除了 wwwroot 中的 NodeLib 文件夹并执行了 copy:lib @ angular gulp任务。它创建了新的 NodeLib 文件夹,其中只包含 @angular 文件夹。这解决了Visual Studio编译错误问题。
答案 1 :(得分:0)
gulp-tsc didn't seem to make well from 1.2.* to 1.3.* Not sure what the main contributor tries to do there, but 1.3.2 does not work yet for VS2015. IMHO you have 2 options:
work with gulp-tsc from git and copy referenced src directory to NodeLib/ or remove tsconfig.jason from there. I either case you will certainly have other dependencies broken for clean VS build.
you need to copy to NodeLib not only @angular as correctly suggested by Laksiri Fernando, but also every package referenced in your systemjs.config.js file as well as stuff you refer to at _Layout.cshtml environment tag.