node_modules 폴더에서 스크립트 빌드 오류를 가져오는 중입니다.
typescript build를 실행하고 있는데 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): 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(빌드 유형 스크립트 작업을 실행 중입니다. 명령줄에 tsc를 입력하기만 하면 동일한 오류가 발생합니다.)
/// <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']);
저도 이것 때문에 고생했어요.
가져오기 {bootstrap} 행이 포함된 TS 파일의 맨 위에 다음을 추가했습니다.
///<reference path="../node_modules/angular2/typings/browser.d.ts"/>
물론 해당 파일의 경로가 다를 수 있습니다.
ES5를 대상으로 하는 경우 tsconfig.json 파일에 "node_modules/typescript/lib/lib.es6.d.ts"를 추가합니다.
{
"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"
]
}
추가할 수 있습니다.skipLibCheck
와의 재산.true
에 가치를 부여합니다.tsconfig.json
:
{
"compilerOptions": {
[...]
"skipLibCheck": true
},
"include": ["./src/**/*.*"],
"exclude": [
"node_modules"
]
}
이 속성을 사용하면 형식 체크인을 선언 파일로 건너뜁니다.*.d.ts
)
이 해결책은
/// <reference path="../typings/browser.d.ts" />
import {bootstrap} from 'angular2/platform/browser';
import {AppComponent} from './app/main';
bootstrap(AppComponent);
gulpjs를 사용할 때는 잘 작동하지만, 다음과 같이 소스 파일에 주석을 채우는 대신 해당 gulpjs 작업의 소스에 직접 타이핑 파일을 추가하는 것을 선호합니다.
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/'));
});
RC1 데모에서 심은 다음에 의해 제공됩니다.core-js
모듈 및 유형 정의는 에 의해 관리됩니다.typings
도구. 추가typings/index.d.ts
로.gulp.src
문제를 해결해야 합니다.
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());
저도 같은 문제가 있었습니다. "npm start"가 아니라 "npm runlite"로 실행해 보십시오.그것은 사용하기에 훨씬 더 편리합니다.
언급URL : https://stackoverflow.com/questions/35382157/typescript-build-getting-errors-from-node-modules-folder
'sourcetip' 카테고리의 다른 글
현재 분기를 다른 분기로 병합하는 방법 (0) | 2023.07.07 |
---|---|
STRING_AGG에서 DISTINCT 값 생성 (0) | 2023.07.02 |
파이썬에서 0xbin()이 False를 반환하는 이유는 무엇입니까? (0) | 2023.07.02 |
Oracle : LEFT JOIN 사용 시 구체화된 보기가 작동하지 않음 (0) | 2023.07.02 |
mongoDB에 지리공간 정보를 저장하는 방법 (0) | 2023.07.02 |