当前位置: 首页 > 知识库问答 >
问题:

错误TS2304:找不到名称“Map”。具有angular 2和.NET内核

陆阳曜
2023-03-14

当我在Task Run Explorer中编译时,我从一个大口中得到了这个错误,这很奇怪,因为我没有改变任何东西...无论如何,我在网上搜索,找到了一些解决方案,但都不起作用。

错误1

{
  "compileOnSave": false,
  "compilerOptions": {
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "module": "system",
    "moduleResolution": "node",
    "noImplicitAny": false,
    "noEmitOnError": false,
    "removeComments": false,
    "target": "es5"
  },

  "exclude": [
    "node_modules",
    "wwwroot"
  ]
}
{
  "version": "1.0.0",
  "name": "testapp.web",
  "private": true,
  "dependencies": {
    "@angular/common": "2.0.0-rc.5",
    "@angular/compiler": "2.0.0-rc.5",
    "@angular/core": "2.0.0-rc.5",
    "@angular/forms": "0.3.0",
    "@angular/http": "2.0.0-rc.5",
    "@angular/platform-browser": "2.0.0-rc.5",
    "@angular/platform-browser-dynamic": "2.0.0-rc.5",
    "@angular/router": "3.0.0-rc.1",
    "@angular/upgrade": "2.0.0-rc.5",
    "core-js": "^2.4.1",
    "reflect-metadata": "^0.1.8",
    "rxjs": "5.0.0-beta.6",
    "systemjs": "^0.19.37",
    "typings": "^2.1.0",
    "zone.js": "^0.6.12"
  },
  "devDependencies": {
    "gulp": "^3.9.1",
    "gulp-clean": "^0.3.2",
    "gulp-concat": "^2.6.0",
    "gulp-less": "^3.1.0",
    "gulp-sourcemaps": "^1.6.0",
    "gulp-typescript": "^2.13.6",
    "gulp-uglify": "^2.0.0",
    "typescript": "^2.2.1" 
  },
  "scripts": {
    "postinstall": "typings install dt~core-js --global"
  }
} 
{
  "compileOnSave": false,
  "compilerOptions": {
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "module": "system",
    "moduleResolution": "node",
    "noImplicitAny": false,
    "noEmitOnError": false,
    "removeComments": false,
    **"target": "es6" <<-- CHANGE**
  },

  "exclude": [
    "node_modules",
    "wwwroot"
  ]
}
{
  "version": "1.0.0",
  "name": "testapp.web",
  "private": true,
  "dependencies": {
    "@angular/common": "2.0.0-rc.5",
    "@angular/compiler": "2.0.0-rc.5",
    "@angular/core": "2.0.0-rc.5",
    "@angular/forms": "0.3.0",
    "@angular/http": "2.0.0-rc.5",
    "@angular/platform-browser": "2.0.0-rc.5",
    "@angular/platform-browser-dynamic": "2.0.0-rc.5",
    "@angular/router": "3.0.0-rc.1",
    "@angular/upgrade": "2.0.0-rc.5",
    "core-js": "^2.4.1",
    "reflect-metadata": "^0.1.8",
    "rxjs": "5.0.0-beta.6",
    "systemjs": "^0.19.37",
    "typings": "^2.1.0",
    "zone.js": "^0.6.12",
    **"es6-promise": "3.2.1",  <<-- CHANGE
    "es6-shim": "0.35.1"**
  },
  "devDependencies": {
    "gulp": "^3.9.1",
    "gulp-clean": "^0.3.2",
    "gulp-concat": "^2.6.0",
    "gulp-less": "^3.1.0",
    "gulp-sourcemaps": "^1.6.0",
    "gulp-typescript": "^2.13.6",
    "gulp-uglify": "^2.0.0",
    "typescript": "^2.2.1" 
  },
  "scripts": {
    "postinstall": "typings install dt~core-js --global"
  }
}

GulpuglifyError:无法缩小JavaScript

如果我做第二个解决方案,我会不会与兼容旧浏览器的问题?

共有1个答案

丁念
2023-03-14

这是我的一口。js

var gulp = require('gulp'),
    gp_clean = require('gulp-clean'),
    gp_concat = require('gulp-concat'),
///    gp_less = require('gulp-less'),
    gp_sourcemaps = require('gulp-sourcemaps'),
    gp_typescript = require('gulp-typescript'),
    gp_uglify = require('gulp-uglify');
    gp_pump = require('pump');

/// Define paths
var srcPaths = {
    app: ['Scripts/app/main.ts', 'Scripts/app/**/*.ts'],
    js: [
        'Scripts/js/**/*.js',
        'node_modules/core-js/client/shim.min.js',
        'node_modules/zone.js/dist/zone.js',
        'node_modules/reflect-metadata/Reflect.js',
        'node_modules/systemjs/dist/system.src.js',
        'node_modules/typescript/lib/typescript.js'
    ],
    js_angular: [
        'node_modules/@angular/**'
    ],
    js_rxjs: [
        'node_modules/rxjs/**'
    ]
    ///,
    ///less: [
    ///    'Scripts/less/**/*.less'
    ///]
};

var destPaths = {
    app: 'wwwroot/app/',
    css: 'wwwroot/css',
    js: 'wwwroot/js/',
    js_angular: 'wwwroot/js/@angular/',
    js_rxjs: 'wwwroot/js/rxjs/'
};

// Compile, minify and create sourcemaps all TypeScript files and place them to wwwroot/app, together with their js.map files.
gulp.task('app', ['app_clean'], function () {
    return gulp.src(srcPaths.app)
        .pipe(gp_sourcemaps.init())
        .pipe(gp_typescript(require('./tsconfig.json').compilerOptions))
        .pipe(gp_uglify({ mangle: false }))
        .pipe(gp_sourcemaps.write('/'))
        .pipe(gulp.dest(destPaths.app));
});

// Delete wwwroot/app contents
gulp.task('app_clean', function () {
    return gulp.src(destPaths.app + "*.*", { read: false })
    .pipe(gp_clean({ force: true }));
});

// Copy all JS files from external libraries to wwwroot/js
gulp.task('js', function () {
    gulp.src(srcPaths.js_angular)
        .pipe(gulp.dest(destPaths.js_angular));
    gulp.src(srcPaths.js_rxjs)
        .pipe(gulp.dest(destPaths.js_rxjs));
    return gulp.src(srcPaths.js)
        .pipe(gulp.dest(destPaths.js));
});

// Delete wwwroot/js contents
gulp.task('js_clean', function () {
    return gulp.src(destPaths.js + "*.*", { read: false })
    .pipe(gp_clean({ force: true }));
});

//// Process all LESS files and output the resulting CSS in wwwroot/css
///gulp.task('less', ['less_clean'], function () {
///    return gulp.src(srcPaths.less)
///        .pipe(gp_less())
///        .pipe(gulp.dest(destPaths.css));
//});

//// Delete wwwroot/css contents
///gulp.task('less_clean', function () {
///    return gulp.src(destPaths.css + "*.*", { read: false })
///        .pipe(gp_clean({ force: true }));
//});

// Watch specified files and define what to do upon file changes
gulp.task('watch', function () {
    gulp.watch([srcPaths.app, srcPaths.js], ['app', 'js']);
});

gulp.task('compress', function (cb) {
    pump([
          gulp.src(srcPaths.js),
          uglify(),
          gulp.dest(destPaths.js)
    ],
      cb
    );
});

// Global cleanup task
gulp.task('cleanup', ['app_clean', 'js_clean']);

// Define the default task so it will launch all other tasks
gulp.task('default', ['app', 'js', 'watch']);
 类似资料:
  • 我是angular 2和typescript的新手,正在尝试为我的弹出窗口调用RocketLaunch函数。 如果我在弹出窗口外声明它不调用,但如果我在弹出窗口内移动它抛出此错误: 错误TS2304:找不到名称“$event” 提供以下相关代码和错误:

  • 我试图启动并运行我的第一个TypeScript和DefinitelyTyped Node.js应用程序,但遇到了一些错误。 当我尝试传输一个简单的TypeScript node.js页面时,我收到错误“TS2304:无法找到名称'require'”。我已经阅读了其他几次发生在Stack ;溢出上的此错误,我认为我没有类似的问题。我正在shell提示符下运行命令: 该文件的内容为: 在行上抛出错误。

  • 问题内容: 我正在尝试启动并运行我的第一个TypeScript和DefinitelyTyped Node.js应用程序,并且遇到一些错误。 尝试转换简单的TypeScript Node.js页面时,出现错误“ TS2304:找不到名称’require’”。我已经阅读了Stack Overflow上多次出现此错误的信息,但我认为我没有类似的问题。我在shell提示符下运行命令: 该文件的内容是: 错

  • 问题内容: 我正在尝试使用TypeScript在NodeJS中进行base64编码。 以下代码在JavaScript中可以正常工作。 当我在TypeScript中编写相同的内容并进行编译时,我得到Buffer is not found错误。 有人可以帮我在TypeScript中做同样的事情。 问题答案: 在顶部添加以下行: 它应该编译没有错误。 使用内置于库或其他全局对象中的节点需要声明,您可以像

  • 我正在构建一个有角度的Firebase web应用程序,由于一些复杂的查询,我开始从Firebase中寻找云函数。 我的项目看起来像: 我遵循了经典教程:https://firebase.google.com/docs/functions/get-started 但是使用Firebase部署仅功能时的问题: 任何想法?我做错什么了吗? 版本:“firebase”:“^5.0.4”firebase函

  • 我已经广泛地搜索了这个问题,但没有找到任何修复它的方法。我正在尝试使用webpack来运行单个jasmine测试。我试图在Angular网站上遵循教程,但它...不是真的正确或完整。 null