Typescript构建从node_modules文件夹中获取错误 [英] Typescript build getting errors from node_modules folder
问题描述
我正在运行一个打字稿,并在node_modules中获取错误。为什么它不忽略这个文件夹?我在我的tsconfig.json的排除部分。真奇怪的是,我有另一个项目,我已经做了文件比较,即使gulpfile.js,tsconfig.json和node_modules文件夹相同,它也不会抛出这些错误。
错误:
c:/ dev / streak-maker / node_modules / angular2 / src / core / change_detection / parser / locals.d.ts(3,14):错误TS2304:找不到名称'Map'。
c:/Dev/streak-maker/node_modules/angular2/src/core/change_detection/parser/locals.d.ts(4,42):错误TS2304:找不到名称'Map'。
c:/Dev/streak-maker/node_modules/angular2/src/core/debug/debug_node.d.ts(14,13):错误TS2304:找不到名称'Map'。
c:/Dev/streak-maker/node_modules/angular2/src/core/debug/debug_node.d.ts(24,17):错误TS2304:找不到名称'Map'。
c:/Dev/streak-maker/node_modules/angular2/src/core/debug/debug_node.d.ts(25,17):错误TS2304:找不到名称'Map'。
c:/Dev/streak-maker/node_modules/angular2/src/core/di/provider.d.ts(436,103):错误TS2304:找不到名称'Map'。
c:/Dev/streak-maker/node_modules/angular2/src/core/di/provider.d.ts(436,135):错误TS2304:找不到名称'Map'。
c:/Dev/streak-maker/node_modules/angular2/src/core/render/api.d.ts(13,13):错误TS2304:找不到名称'Map'。
c:/Dev/streak-maker/node_modules/angular2/src/core/render/api.d.ts(14,84):错误TS2304:找不到名称'Map'。
c:/Dev/streak-maker/node_modules/angular2/src/facade/collection.d.ts(1,25):错误TS2304:找不到名称'MapConstructor'。
c:/Dev/streak-maker/node_modules/angular2/src/facade/collection.d.ts(2,25):错误TS2304:找不到名称'SetConstructor'。
c:/Dev/streak-maker/node_modules/angular2/src/facade/collection.d.ts(4,27):错误TS2304:找不到名称'Map'。
c:/Dev/streak-maker/node_modules/angular2/src/facade/collection.d.ts(4,39):错误TS2304:找不到名称'Map'。
c:/Dev/streak-maker/node_modules/angular2/src/facade/collection.d.ts(7,9):错误TS2304:找不到名称'Map'。
c:/Dev/streak-maker/node_modules/angular2/src/facade/collection.d.ts(8,30):错误TS2304:找不到名称'Map'。
c:/Dev/streak-maker/node_modules/angular2/src/facade/collection.d.ts(11,43):错误TS2304:找不到名称'Map'。
c:/Dev/streak-maker/node_modules/angular2/src/facade/collection.d.ts(12,27):错误TS2304:找不到名称'Map'。
c:/Dev/streak-maker/node_modules/angular2/src/facade/collection.d.ts(14,23):错误TS2304:找不到名称'Map'。
c:/Dev/streak-maker/node_modules/angular2/src/facade/collection.d.ts(15,25):错误TS2304:找不到名称'Map'。
c:/Dev/streak-maker/node_modules/angular2/src/facade/collection.d.ts(95,41):错误TS2304:找不到名称'Set'。
c:/Dev/streak-maker/node_modules/angular2/src/facade/collection.d.ts(96,22):错误TS2304:找不到名称'Set'。
c:/Dev/streak-maker/node_modules/angular2/src/facade/collection.d.ts(97,25):错误TS2304:找不到名称'Set'。
c:/Dev/streak-maker/node_modules/angular2/src/facade/lang.d.ts(13,17):错误TS2304:找不到名称'Map'。
c:/Dev/streak-maker/node_modules/angular2/src/facade/lang.d.ts(14,17):错误TS2304:找不到名称'Set'。
c:/Dev/streak-maker/node_modules/angular2/src/facade/lang.d.ts(78,59):错误TS2304:找不到名称'Map'。
c:/Dev/streak-maker/node_modules/angular2/src/facade/promise.d.ts(1,10):错误TS2304:找不到'Promise'的名称。
c:/Dev/streak-maker/node_modules/angular2/src/facade/promise.d.ts(3,14):错误TS2304:找不到名字'Promise'。
c:/Dev/streak-maker/node_modules/angular2/src/facade/promise.d.ts(8,32):错误TS2304:找不到名字'Promise'。
c:/Dev/streak-maker/node_modules/angular2/src/facade/promise.d.ts(9,38):错误TS2304:找不到名字'Promise'。
c:/Dev/streak-maker/node_modules/angular2/src/facade/promise.d.ts(10,35):错误TS2304:找不到名字'Promise'。
c:/Dev/streak-maker/node_modules/angular2/src/facade/promise.d.ts(10,93):错误TS2304:找不到名字'Promise'。
c:/Dev/streak-maker/node_modules/angular2/src/facade/promise.d.ts(11,34):错误TS2304:找不到名字'Promise'。
c:/Dev/streak-maker/node_modules/angular2/src/facade/promise.d.ts(12,32):错误TS2304:找不到'Promise'这个名字。
c:/Dev/streak-maker/node_modules/angular2/src/facade/promise.d.ts(12,149):错误TS2304:找不到名字'Promise'。
c:/Dev/streak-maker/node_modules/angular2/src/facade/promise.d.ts(13,43):错误TS2304:找不到'Promise'的名称。
c:/Dev/streak-maker/node_modules/angular2/src/http/headers.d.ts(43,59):错误TS2304:找不到名称'Map'。
c:/Dev/streak-maker/node_modules/angular2/src/http/url_search_params.d.ts(11,16):错误TS2304:找不到名称'Map'。
c:/Dev/streak-maker/node_modules/angular2/src/platform/browser/browser_adapter.d.ts(75,33):错误TS2304:找不到名称'Map'。
c:/Dev/streak-maker/node_modules/angular2/src/platform/dom/dom_adapter.d.ts(85,42):错误TS2304:找不到名称'Map'。
c:/Dev/streak-maker/node_modules/rxjs/CoreOperators.d.ts(22,67):错误TS2304:找不到'Promise'的名称。
c:/Dev/streak-maker/node_modules/rxjs/CoreOperators.d.ts(72,67):错误TS2304:找不到名字'Promise'。
c:/Dev/streak-maker/node_modules/rxjs/CoreOperators.d.ts(77,31):错误TS2304:找不到名字'PromiseConstructor'。
c:/Dev/streak-maker/node_modules/rxjs/CoreOperators.d.ts(77,54):错误TS2304:找不到'Promise'的名称。
c:/Dev/streak-maker/node_modules/rxjs/Observable.d.ts(65,67):错误TS2304:找不到名字'PromiseConstructor'。
c:/Dev/streak-maker/node_modules/rxjs/Observable.d.ts(65,88):错误TS2304:找不到名称'Promise'。
c:/Dev/streak-maker/node_modules/rxjs/Observable.d.ts(72,84):错误TS2304:找不到名字'Promise'。
c:/Dev/streak-maker/node_modules/rxjs/Observable.d.ts(77,38):错误TS2304:找不到'Promise'的名称。
c:/Dev/streak-maker/node_modules/rxjs/Observable.d.ts(100,66):错误TS2304:找不到名字'Promise'。
c:/Dev/streak-maker/node_modules/rxjs/Observable.d.ts(154,66):错误TS2304:找不到名字'Promise'。
c:/Dev/streak-maker/node_modules/rxjs/Observable.d.ts(159,31):错误TS2304:找不到名字'PromiseConstructor'。
c:/Dev/streak-maker/node_modules/rxjs/Observable.d.ts(159,54):错误TS2304:找不到'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(我正在运行build-typescript任务 - 刚刚出现相同的错误在命令行键入tsc)
///< binding Build ='default'/>
$ b $ 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 /;
varpath = {
webroot:webroot,
src:appsource,$ b $ app:appout,
jspm:jspmsource,
jspm_out: jspmout
};
gulp.task('watch',['watch-typingcript','watch-html']);
$ b $ gulp.task('watch-typecript',function(){
gulp.watch(paths.src +'/**/*.ts',['build-typescript' ]);
});
$ b $ gulp.task('clean-typescript',function(){
del([paths.app +'/**/*.ts']);
} );
$ b $ 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));
});
$ b gulp.task('watch-html',function(){
gulp.watch(paths.src +'/**/*.html',['copy-html' ]);
});
$ b $ gulp.task('clean-html',function(){
del([paths.app +'/**/*.html']);
} );
$ b $ gulp.task('copy-html',['clean-html'],function(){
gulp.src(paths.src +'/**/*.html ')
.pipe(gulp.dest(paths.app));
});
$ b gulp.task('copy-jspm',['clean-jspm','copy-config'],function(){
gulp.src(paths.jspm +* * / *。{js,css,map})
.pipe(gulp.dest(paths.jspm_out));
});
$ b $ gulp.task('clean-jspm',function(){
del([paths.jspm_out +** / *。*]);
}) ;
$ b $ 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']);
我也在为此付出努力。
我将以下内容添加到包含import {bootstrap}行的TS文件的顶部:
///< reference path =../ node_modules / angular2 / typings / browser.d.ts/>
您的路径对于该文件可能会有所不同。
I am running a typescript build and getting errors in node_modules. Why isn't it ignoring this folder? I have it in the exclude section of my tsconfig.json. The really strange thing is that I have another project that I have done a file comparison with and it does not throw these errors even though gulpfile.js, tsconfig.json and the node_modules folders are identical. What else can I check?
Errors:
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 (I am running the build-typescript task - I get the same errors when just typing tsc at the command line)
/// <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']);
I was struggling with this as well.
I added the following to the top of the TS file that contained the import {bootstrap} line:
///<reference path="../node_modules/angular2/typings/browser.d.ts"/>
Your path may be different of course for that file.
这篇关于Typescript构建从node_modules文件夹中获取错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!