2016-02-13 6 views
10

Ich bin ein Typoskript Build und bekomme Fehler in node_modules. Warum ignoriert es diesen Ordner nicht? Ich habe es im Ausschlussbereich meiner tsconfig.json. Das wirklich seltsame Ding ist, dass ich ein anderes Projekt habe, mit dem ich einen Dateivergleich gemacht habe, und es wirft diese Fehler nicht, obwohl gulpfile.js, tsconfig.json und die node_modules Ordner identisch sind. Was kann ich noch überprüfen?Typescript Build Fehler aus dem Ordner "node_modules" erhalten

Fehler:

c:/Dev/streak-maker/node_modules/angular2/src/core/change_detection/parser/locals.d.ts(3,14): error TS2304: Cannot find name 'Map'. 
c:/Dev/streak-maker/node_modules/angular2/src/core/change_detection/parser/locals.d.ts(4,42): error TS2304: Cannot find name 'Map'. 
c:/Dev/streak-maker/node_modules/angular2/src/core/debug/debug_node.d.ts(14,13): error TS2304: Cannot find name 'Map'. 
c:/Dev/streak-maker/node_modules/angular2/src/core/debug/debug_node.d.ts(24,17): error TS2304: Cannot find name 'Map'. 
c:/Dev/streak-maker/node_modules/angular2/src/core/debug/debug_node.d.ts(25,17): error TS2304: Cannot find name 'Map'. 
c:/Dev/streak-maker/node_modules/angular2/src/core/di/provider.d.ts(436,103): error TS2304: Cannot find name 'Map'. 
c:/Dev/streak-maker/node_modules/angular2/src/core/di/provider.d.ts(436,135): error TS2304: Cannot find name 'Map'. 
c:/Dev/streak-maker/node_modules/angular2/src/core/render/api.d.ts(13,13): error TS2304: Cannot find name 'Map'. 
c:/Dev/streak-maker/node_modules/angular2/src/core/render/api.d.ts(14,84): error TS2304: Cannot find name 'Map'. 
c:/Dev/streak-maker/node_modules/angular2/src/facade/collection.d.ts(1,25): error TS2304: Cannot find name 'MapConstructor'. 
c:/Dev/streak-maker/node_modules/angular2/src/facade/collection.d.ts(2,25): error TS2304: Cannot find name 'SetConstructor'. 
c:/Dev/streak-maker/node_modules/angular2/src/facade/collection.d.ts(4,27): error TS2304: Cannot find name 'Map'. 
c:/Dev/streak-maker/node_modules/angular2/src/facade/collection.d.ts(4,39): error TS2304: Cannot find name 'Map'. 
c:/Dev/streak-maker/node_modules/angular2/src/facade/collection.d.ts(7,9): error TS2304: Cannot find name 'Map'. 
c:/Dev/streak-maker/node_modules/angular2/src/facade/collection.d.ts(8,30): error TS2304: Cannot find name 'Map'. 
c:/Dev/streak-maker/node_modules/angular2/src/facade/collection.d.ts(11,43): error TS2304: Cannot find name 'Map'. 
c:/Dev/streak-maker/node_modules/angular2/src/facade/collection.d.ts(12,27): error TS2304: Cannot find name 'Map'. 
c:/Dev/streak-maker/node_modules/angular2/src/facade/collection.d.ts(14,23): error TS2304: Cannot find name 'Map'. 
c:/Dev/streak-maker/node_modules/angular2/src/facade/collection.d.ts(15,25): error TS2304: Cannot find name 'Map'. 
c:/Dev/streak-maker/node_modules/angular2/src/facade/collection.d.ts(95,41): error TS2304: Cannot find name 'Set'. 
c:/Dev/streak-maker/node_modules/angular2/src/facade/collection.d.ts(96,22): error TS2304: Cannot find name 'Set'. 
c:/Dev/streak-maker/node_modules/angular2/src/facade/collection.d.ts(97,25): error TS2304: Cannot find name 'Set'. 
c:/Dev/streak-maker/node_modules/angular2/src/facade/lang.d.ts(13,17): error TS2304: Cannot find name 'Map'. 
c:/Dev/streak-maker/node_modules/angular2/src/facade/lang.d.ts(14,17): error TS2304: Cannot find name 'Set'. 
c:/Dev/streak-maker/node_modules/angular2/src/facade/lang.d.ts(78,59): error TS2304: Cannot find name 'Map'. 
c:/Dev/streak-maker/node_modules/angular2/src/facade/promise.d.ts(1,10): error TS2304: Cannot find name 'Promise'. 
c:/Dev/streak-maker/node_modules/angular2/src/facade/promise.d.ts(3,14): error TS2304: Cannot find name 'Promise'. 
c:/Dev/streak-maker/node_modules/angular2/src/facade/promise.d.ts(8,32): error TS2304: Cannot find name 'Promise'. 
c:/Dev/streak-maker/node_modules/angular2/src/facade/promise.d.ts(9,38): error TS2304: Cannot find name 'Promise'. 
c:/Dev/streak-maker/node_modules/angular2/src/facade/promise.d.ts(10,35): error TS2304: Cannot find name 'Promise'. 
c:/Dev/streak-maker/node_modules/angular2/src/facade/promise.d.ts(10,93): error TS2304: Cannot find name 'Promise'. 
c:/Dev/streak-maker/node_modules/angular2/src/facade/promise.d.ts(11,34): error TS2304: Cannot find name 'Promise'. 
c:/Dev/streak-maker/node_modules/angular2/src/facade/promise.d.ts(12,32): error TS2304: Cannot find name 'Promise'. 
c:/Dev/streak-maker/node_modules/angular2/src/facade/promise.d.ts(12,149): error TS2304: Cannot find name 'Promise'. 
c:/Dev/streak-maker/node_modules/angular2/src/facade/promise.d.ts(13,43): error TS2304: Cannot find name 'Promise'. 
c:/Dev/streak-maker/node_modules/angular2/src/http/headers.d.ts(43,59): error TS2304: Cannot find name 'Map'. 
c:/Dev/streak-maker/node_modules/angular2/src/http/url_search_params.d.ts(11,16): error TS2304: Cannot find name 'Map'. 
c:/Dev/streak-maker/node_modules/angular2/src/platform/browser/browser_adapter.d.ts(75,33): error TS2304: Cannot find name 'Map'. 
c:/Dev/streak-maker/node_modules/angular2/src/platform/dom/dom_adapter.d.ts(85,42): error TS2304: Cannot find name 'Map'. 
c:/Dev/streak-maker/node_modules/rxjs/CoreOperators.d.ts(22,67): error TS2304: Cannot find name 'Promise'. 
c:/Dev/streak-maker/node_modules/rxjs/CoreOperators.d.ts(72,67): error TS2304: Cannot find name 'Promise'. 
c:/Dev/streak-maker/node_modules/rxjs/CoreOperators.d.ts(77,31): error TS2304: Cannot find name 'PromiseConstructor'. 
c:/Dev/streak-maker/node_modules/rxjs/CoreOperators.d.ts(77,54): error TS2304: Cannot find name 'Promise'. 
c:/Dev/streak-maker/node_modules/rxjs/Observable.d.ts(65,67): error TS2304: Cannot find name 'PromiseConstructor'. 
c:/Dev/streak-maker/node_modules/rxjs/Observable.d.ts(65,88): error TS2304: Cannot find name 'Promise'. 
c:/Dev/streak-maker/node_modules/rxjs/Observable.d.ts(72,84): error TS2304: Cannot find name 'Promise'. 
c:/Dev/streak-maker/node_modules/rxjs/Observable.d.ts(77,38): error TS2304: Cannot find name 'Promise'. 
c:/Dev/streak-maker/node_modules/rxjs/Observable.d.ts(100,66): error TS2304: Cannot find name 'Promise'. 
c:/Dev/streak-maker/node_modules/rxjs/Observable.d.ts(154,66): error TS2304: Cannot find name 'Promise'. 
c:/Dev/streak-maker/node_modules/rxjs/Observable.d.ts(159,31): error TS2304: Cannot find name 'PromiseConstructor'. 
c:/Dev/streak-maker/node_modules/rxjs/Observable.d.ts(159,54): error TS2304: Cannot find name 'Promise'. 

tsconfig.js

{ 
    "version": 3, 
    "compilerOptions": { 
    "target": "es5", 
    "module": "system", 
    "moduleResolution": "node", 
    "sourceMap": false, 
    "emitDecoratorMetadata": true, 
    "experimentalDecorators": true, 
    "removeComments": false, 
    "noImplicitAny": false 
    }, 
    "exclude": [ 
    "node_modules", 
    "jspm_packages" 
    ] 
} 

gulpfile.js (Ich bin die Build-Typoskript Aufgabe ausgeführt wird - ich die gleichen Fehler erhalten, wenn nur tsc in der Befehlszeile eingeben)

/// <binding Build='default' /> 

var del = require('del'), 
    gulp = require("gulp"), 
    ts = require('gulp-typescript'), 
    watch = require('gulp-watch'); 

var webproj = "./src/StreakMaker.Web/"; 
var webroot = webproj + "wwwroot/"; 
var appsource = webproj + "App/"; 
var appout = webroot + "app/"; 
var jspmsource = "./jspm_packages/"; 
var jspmout = webroot + "jspm_packages/"; 

var paths = { 
    webroot: webroot, 
    src: appsource, 
    app: appout, 
    jspm: jspmsource, 
    jspm_out: jspmout 
}; 

gulp.task('watch', ['watch-typescript', 'watch-html']); 

gulp.task('watch-typescript', function(){ 
    gulp.watch(paths.src + '/**/*.ts', ['build-typescript']); 
}); 

gulp.task('clean-typescript', function() { 
    del([paths.app + '/**/*.ts']); 
}); 

gulp.task('build-typescript', ['clean-typescript'], function() { 
    var tsProject = ts.createProject('./tsconfig.json'); 

    gulp.src(paths.src + '/**/*.ts') 
     .pipe(ts(tsProject)) 
     .pipe(gulp.dest(paths.app)); 
}); 

gulp.task('watch-html', function() { 
    gulp.watch(paths.src + '/**/*.html', ['copy-html']); 
}); 

gulp.task('clean-html', function() { 
    del([paths.app + '/**/*.html']); 
}); 

gulp.task('copy-html', ['clean-html'], function() { 
    gulp.src(paths.src + '/**/*.html') 
     .pipe(gulp.dest(paths.app)); 
}); 

gulp.task('copy-jspm', ['clean-jspm', 'copy-config'], function() { 
    gulp.src(paths.jspm + "**/*.{js,css,map}") 
     .pipe(gulp.dest(paths.jspm_out)); 
}); 

gulp.task('clean-jspm', function(){ 
    del([paths.jspm_out + "**/*.*"]); 
}); 

gulp.task('copy-config', ['clean-config'], function(){ 
    gulp.src("./config.js") 
     .pipe(gulp.dest(paths.webroot)); 
}); 

gulp.task('clean-config', function(){ 
    del(paths.webroot + 'config.js'); 
}); 

gulp.task('default', ['build-typescript', 'copy-html', 'copy-jspm']); 

Antwort

29

Ich hatte auch damit zu kämpfen.

Ich habe folgendes an die Spitze der TS-Datei, die den Import {Bootstrap} Zeile enthalten:

///<reference path="../node_modules/angular2/typings/browser.d.ts"/> 

kann Ihr Weg für diese Datei natürlich anders sein.

+1

funktioniert perfekt. –

+2

Dies ist sehr nützlich (+1), und wenn Sie dem [quickstart on angular.io] (https://angular.io/docs/ts/latest/quickstart.html) folgen, funktioniert das direkt auf die Top-Level-Typings : '/// ' –

+2

funktioniert nicht mehr mit der version rc1 – jaumard

2

Während diese Lösung

/// <reference path="../typings/browser.d.ts" /> 
import {bootstrap} from 'angular2/platform/browser'; 
import {AppComponent} from './app/main'; 

bootstrap(AppComponent); 

funktioniert gut, WENN gulpjs mit ziehe ich es jedoch statt mit Kommentaren Quelldatei bevölkern, ein Zusatz von Typisierungen direkt an der Quelle der entsprechenden gulpjs Aufgabe Datei, wie zum Beispiel:

gulp.task('typescript', function() { 
    return gulp 
    .src([ 
     'typings/browser.d.ts', 
     tsSrc + '**/*.ts' 
    ]) 
    .pipe(sourcemaps.init()) 
    .pipe(typescript(tscConfig.compilerOptions)) 
    .pipe(sourcemaps.write('.')) 
    .pipe(gulp.dest(appSrc + 'js/')); 
}); 
1

In RC1 Demo, die Scheibe durch die core-js Modul und Typdefinitionen zur Verfügung gestellt wird durch das typings Tool verwaltet. Hinzufügen typings/index.d.ts zu gulp.src sollte das Problem beheben:

function buildTypeScriptFn(files) { 
    files = files || ['app/**/*.ts','typings/index.d.ts']; 

    return function() { 
    var tsResult = gulp.src(files) 
     .pipe(changed(paths.dirs.build, { extension: '.js' })) 
     .pipe(ts(tscConfig.compilerOptions)); 

    return merge(tsResult.dts, tsResult.js) 
     .pipe(gulp.dest(paths.dirs.build)); 
    } 
} 

gulp.task('ts', buildTypeScriptFn()); 
+0

Vielen Dank, dies funktioniert – meffect

1

Ich hatte das gleiche Problem, versuchen Sie einfach laufen nicht mit "npm beginnen", aber mit "npm laufen lite". Es ist viel bequemer zu benutzen.

+0

das hat für mich funktioniert.Wird es in der Zukunft irgendwelche Probleme geben? –

14

Wenn Sie ES5 Targeting sind, fügen Sie "node_modules/Typoskript/lib/lib.es6.d.ts" Datei tsconfig.json:

{ 
    "compilerOptions": { 
     "module": "commonjs", 
     "target": "es5", 
     "noImplicitAny": false, 
     "outDir": "built", 
     "rootDir": ".", 
     "sourceMap": false 
    }, 
    "files": [ 
     "helloworld.ts", 
     "node_modules/typescript/lib/lib.es6.d.ts" 
    ], 
    "exclude": [ 
     "node_modules" 
    ] 
} 
+2

Neuling-Kommentar. Dies in Visual Studio 2015 zu tun, hat mir 43k neue typescript build errors. – bbsimonbb

+0

Das funktionierte für mich, als einige Module sagten, sie könnten ihre Abhängigkeiten nicht finden. –

Verwandte Themen