为什么我收到TypeError system.config不是函数?

时间:2019-09-20 11:17:20

标签: angular typescript

我收到此错误 Error message in console

这是我的文件: systemjs.config.js

/**
 * System configuration for Angular samples
 * Adjust as necessary for your application needs.
 */
(function (global) {
  System.config({
    paths: {
      // paths serve as alias
      'npm:': 'node_modules/'
    },
    // map tells the System loader where to look for things
    map: {
      // our app is within the app folder
      'app': 'app',

      // angular bundles
      '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
      '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
      '@angular/common/http': 'npm:@angular/common/bundles/common-http.umd.js',
      '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
      '@angular/animations': "npm:@angular/animations/bundles/animations.umd.js",
      '@angular/animations/browser': 'npm:@angular/animations/bundles/animations-browser.umd.js',
      '@angular/http': 'npm:@angular/http/bundles/http.umd.js',
      '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
      '@angular/router': 'npm:@angular/router/bundles/router.umd.js',
      '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
      '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
      '@angular/platform-browser/animations': 'npm:@angular/platform-browser/bundles/platform-browser-animations.umd.js',
      '@angular/material': 'npm:@angular/material/bundles/material.umd.js',
      '@angular/cdk': 'npm:@angular/cdk/bundles/cdk.umd.js',



      // other libraries
      'rxjs':                      'npm:rxjs',
      'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js',
      'ngx-pagination': 'npm:ngx-pagination/dist/ngx-pagination.umd.js'
    },
    // packages tells the System loader how to load when no filename and/or no extension
    packages: {
      app: {
        defaultExtension: 'js',
        main:'main.js'

      },
      rxjs: {
        defaultExtension: 'js'
      },

      'ngx-pagination': { defaultExtension: 'js' }
    }
  });
})(this);

_Layout.cshtml(index.html)

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>@ViewBag.Title - My ASP.NET Application</title>
    @Styles.Render("~/Content/css")
    @Scripts.Render("~/bundles/modernizr")

    <!-- Polyfill(s) for older browsers -->
    <script src="/node_modules/core-js/client/shim.min.js"></script>

     <script src="/node_modules/zone.js/dist/zone.js"></script>
     <script src="/node_modules/systemjs/dist/system.js"></script>

     <script src="/systemjs.config.js"></script>
     <script>
         System.import('app').catch(function (err) { console.log(err); });
     </script>

</head>
<body>

    <div class="container body-content">
        @RenderBody()
        <hr />
        <footer>
            <p>&copy; @DateTime.Now.Year - My ASP.NET Application</p>
        </footer>
    </div>

    @Scripts.Render("~/bundles/jquery")
    @Scripts.Render("~/bundles/bootstrap")
    @RenderSection("scripts", required: false)
</body>
</html>

package.json

{
  "name": "angular-quickstart",
  "version": "1.0.0",
  "description": "QuickStart package.json from the documentation, supplemented with testing support",
  "scripts": {
    "build": "tsc -p src/",
    "build:watch": "tsc -p src/ -w",
    "build:e2e": "tsc -p e2e/",
    "serve": "lite-server -c=bs-config.json",
    "serve:e2e": "lite-server -c=bs-config.e2e.json",
    "prestart": "npm run build",
    "start": "concurrently \"npm run build:watch\" \"npm run serve\"",
    "pree2e": "npm run build:e2e",
    "e2e": "concurrently \"npm run serve:e2e\" \"npm run protractor\" --kill-others --success first",
    "preprotractor": "webdriver-manager update",
    "protractor": "protractor protractor.config.js",
    "pretest": "npm run build",
    "test": "concurrently \"npm run build:watch\" \"karma start karma.conf.js\"",
    "pretest:once": "npm run build",
    "test:once": "karma start karma.conf.js --single-run",
    "lint": "tslint ./src/**/*.ts -t verbose"
  },
  "keywords": [],
  "author": "",
  "license": "MIT",
  "dependencies": {
    "@angular/animations": "^8.2.7",
    "@angular/cdk": "^8.2.0",
    "@angular/common": "^8.2.7",
    "@angular/compiler": "^8.2.7",
    "@angular/core": "^8.2.7",
    "@angular/forms": "^8.2.7",
    "@angular/http": "^7.2.15",
    "@angular/material": "^8.2.0",
    "@angular/platform-browser": "^8.2.7",
    "@angular/platform-browser-dynamic": "^8.2.7",
    "@angular/router": "^8.2.7",
    "angular": "^1.7.8",
    "angular-animate": "^1.7.8",
    "angular-aria": "^1.7.8",
    "angular-in-memory-web-api": "^0.9.0",
    "angular-material": "^1.1.20",
    "angular-messages": "^1.7.8",
    "core-js": "^2.4.1",
    "ng2-pagination": "^2.0.2",
    "ngx-pagination": "^4.1.0",
    "rxjs": "^6.5.3",
    "systemjs": "^6.1.1",
    "zone.js": "^0.9.1"
  },
  "devDependencies": {
    "@types/jasmine": "^3.4.0",
    "@types/node": "^12.7.5",
    "canonical-path": "1.0.0",
    "codelyzer": "^5.1.1",
    "concurrently": "4.1.2",
    "jasmine-core": "^3.4.0",
    "jasmine-spec-reporter": "^4.2.1",
    "karma": "^4.3.0",
    "karma-chrome-launcher": "^3.1.0",
    "karma-cli": "^2.0.0",
    "karma-jasmine": "^2.0.1",
    "karma-jasmine-html-reporter": "^1.4.2",
    "lite-server": "^2.5.4",
    "lodash": "^4.17.15",
    "protractor": "^5.4.2",
    "rimraf": "^3.0.0",
    "rxjs-tslint": "^0.1.7",
    "tslint": "^5.20.0",
    "typescript": "^3.6.3",
    "webpack": "^4.40.2"
  },
  "repository": {}
}

app.module.ts

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { HttpClientModule } from '@angular/common/http';
import { FormsModule } from '@angular/forms';

import { APP_BASE_HREF } from '@angular/common';
import { routing } from './app.routing';

import { AppComponent } from './app.component';
import { LoginComponent } from './login/login.component';

import { LoginService } from './service/login.service';

import { RegisterComponent } from './register/register.component';
import { RegisterService } from './service/register.service';
import { CategoryManagementService } from './service/category-management';
import { LanguageManagementService } from './service/language-management';

import { AddBookComponent } from './add-book/add-book.component';
import { BookManagementService } from './service/book-management.service';
import { MenuComponent } from './menu/menu.component';
import { DashboardComponent } from './dashboard/dashboard.component';

import { SearchBooksComponent } from './search-books/search-books.component';

import { SearchFilterPipe } from './search-filter.pipe';
import { NgxPaginationModule } from 'ngx-pagination';

@NgModule({
    imports: [BrowserModule, HttpClientModule, FormsModule, routing, NgxPaginationModule],
    declarations: [AppComponent, RegisterComponent, LoginComponent, DashboardComponent, AddBookComponent, MenuComponent, SearchBooksComponent, SearchFilterPipe],
    providers: [{ provide: APP_BASE_HREF, useValue: '/' }, RegisterService, LoginService, BookManagementService, LanguageManagementService, CategoryManagementService],
    bootstrap: [AppComponent]
})
export class AppModule { }

我需要帮助人员,我确实做了很多尝试,但仍然找不到任何解决方案,并且无法启动我的应用程序。我不知道确切的问题是什么,但取决于此错误的原因可能与脚本或软件包有关。我不知道我会对此表示赞赏

0 个答案:

没有答案