错误:http://localhost/node_modules/@types/node/index.d.ts:接口是严格模式下的保留字

时间:2018-03-22 08:53:42

标签: javascript angularjs typescript

我正在 Umbraco 项目中集成 AngularJS 应用程序。我有一个cs-html文件,它调用我的app的main.js文件,并且aplication显示在指定的URL中(在项目运行tsc和build之后所有这些)。

文件夹结构如下:

UmbracoProject/
              |
              | angularCode/
              |              src/
              |              systemjs-angular-loader.js
              |              systemjs.config.js
              |              tsconfig.js
              |
              |node_modules/
                           @types/node/index.d.ts

我必须配置 systemjs.config.js 文件,以便角度应用程序中的导入能够找到node_modules。 (它以这种方式设置,因为在同一个项目中将有其他角度应用程序,以便所有角色应用程序共享相同的node_modules)。

我正在使用fabric.js的一些依赖项,需要 @ types / node / index.d.ts 文件才能运行。

我的systemjs.config.js必须找到以下内容

当我转到设计的网址时,我收到以下错误:

Error: http://localhost/node_modules/@types/node/index.d.ts: interface is a reserved word in strict mode (18:0)
  16 | 
  17 | // This needs to be global to avoid TS2403 in case lib.dom.d.ts is present in the same build
  18 | interface Console {
     | ^
  19 |     Console: typeof NodeJS.Console;
  20 |     assert(value: any, message?: string, ...optionalParams: any[]): void;
  21 |     dir(obj: any, options?: NodeJS.InspectOptions): void;
  Instantiating http://localhost/node_modules/@types/node/index.d.ts

在这类问题上有任何线索吗?

由于

1 个答案:

答案 0 :(得分:0)

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

(function (global) {
  System.config({

    useBundles:'true',

    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': '/LayoutEditor/Client/',

        'plugin-babel': 'npm:/systemjs-plugin-babel/plugin-babel.js',
        'systemjs-babel-build': 'npm:/systemjs-plugin-babel/systemjs-babel-browser.js',
        'systemjs': 'npm:/systemjs/dist/system.js',
        'system-polyfills': 'npm:/systemjs/dist/system-polyfills.js',
        'es6-module-loader': 'npm:/es6-module-loader/dist/es6-module-loader.js',

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

      //angular material and angular./cdk
      '@angular/material': 'npm:@angular/material/bundles/material.umd.js',
      '@angular/material/core': 'npm:@angular/material/bundles/material-core.umd.js',
      '@angular/material/icon':'npm:@angular/material/bundles/material-icon.umd.js',
      '@angular/material/button':'npm:@angular/material/bundles/material-button.umd.js',
      '@angular/material/menu':'npm:@angular/material/bundles/material-menu.umd.js',
      '@angular/material/list': 'npm:@angular/material/bundles/material-list.umd.js',
      '@angular/material/toolbar':'npm:@angular/material/bundles/material-toolbar.umd.js',
      '@angular/material/expansion':'npm:@angular/material/bundles/material-expansion.umd.js',
      '@angular/material/form-field':'npm:@angular/material/bundles/material-form-field.umd.js',
      '@angular/material/input':'npm:@angular/material/bundles/material-input.umd.js',
      '@angular/material/tooltip':'npm:@angular/material/bundles/material-tooltip.umd.js',
      '@angular/material/chips':'npm:@angular/material/bundles/material-chips.umd.js',
      '@angular/material/sidenav':'npm:@angular/material/bundles/material-sidenav.umd.js',
      '@angular/material/dialog':'npm:@angular/material/bundles/material-dialog.umd.js',
      '@angular/material/grid-list':'npm:@angular/material/bundles/material-grid-list.umd.js',
      '@angular/material/progress-spinner':'npm:@angular/material/bundles/material-progress-spinner.umd.js',
      '@angular/material/checkbox':'npm:@angular/material/bundles/material-checkbox.umd.js',
      '@angular/material/slide-toggle':'npm:@angular/material/bundles/material-slide-toggle.umd.js',
      '@angular/material/card':'npm:@angular/material/bundles/material-card.umd.js',
      '@angular/material/divider' :'npm:@angular/material/bundles/material-divider.umd.js',
        // angular/cdk
        '@angular/cdk': 'npm:@angular/cdk/bundles/cdk.umd.js',
        '@angular/cdk/bidi': 'npm:@angular/cdk/bundles/cdk-bidi.umd.js',
        '@angular/cdk/a11y': 'npm:@angular/cdk/bundles/cdk-a11y.umd.js',
        '@angular/cdk/coercion': 'npm:@angular/cdk/bundles/cdk-coercion.umd.js',
        '@angular/cdk/keycodes': 'npm:@angular/cdk/bundles/cdk-keycodes.umd.js',
        '@angular/cdk/overlay': 'npm:@angular/cdk/bundles/cdk-overlay.umd.js',
        '@angular/cdk/portal': 'npm:@angular/cdk/bundles/cdk-portal.umd.js',
        '@angular/cdk/accordion': 'npm:@angular/cdk/bundles/cdk-accordion.umd.js',
        '@angular/cdk/layout': 'npm:@angular/cdk/bundles/cdk-layout.umd.js',
        '@angular/cdk/collections': 'npm:@angular/cdk/bundles/cdk-collections.umd.js',
        '@angular/cdk/observers': 'npm:@angular/cdk/bundles/cdk-observers.umd.js',
        '@angular/cdk/scrolling': 'npm:@angular/cdk/bundles/cdk-scrolling.umd.js',
        '@angular/cdk/table': 'npm:@angular/cdk/bundles/cdk-table.umd.js',
        '@angular/cdk/stepper': 'npm:@angular/cdk/bundles/cdk-stepper.umd.js',
        '@angular/cdk/platform': 'npm:@angular/cdk/bundles/cdk-platform.umd.js',


      //angular animations
      '@angular/animations': 'npm:@angular/animations/bundles/animations.umd.js',
      '@angular/animations/browser': 'npm:@angular/animations/bundles/animations-browser.umd.js',


      //authentication provider
        'angular-oauth2-oidc': 'npm:angular-oauth2-oidc/angular-oauth2-oidc.umd.js',


        //fabricjs and canvas
        'fabric': 'npm:fabric/dist/fabric.js',
        'canvas': 'npm:canvas/index.js',
        'xmldom': 'npm:xmldom/dom.js',
        'url': 'npm:url/url.js',
        'jsdom': 'npm:jsdom/lib/jsdom.js',
        'https': 'npm:@types/node/index.d.ts',
        'http': 'npm:@types/node/index.d.ts',
        'fs': 'npm:@types/node/index.d.ts',



      // other libraries
      'tslib': 'npm:tslib/tslib.js',
      'angular-persistence': 'angular-persistence',
      'rxjs':'npm:rxjs',
      'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js',
      'ngx-color-picker': 'npm:ngx-color-picker/bundles/ngx-color-picker.umd.js',
      'ng2-scroll-to-el': 'npm:ng2-scroll-to-el/bundles/ngScrollTo.umd.js',
      'angular2-draggable': 'npm:angular2-draggable/bundles/angular2-draggable.umd.js',
      'sweetalert2': 'npm:sweetalert2/dist/sweetalert2.js',
      'file-saver': 'npm:file-saver/dist/FileSaver.js',
      'ngresizable': 'npm:ngresizable/ngresizable.bundle.js'



      },

     transpiler: 'plugin-babel',

    // packages tells the System loader how to load when no filename and/or no extension
    packages: {
      app: {
        defaultExtension: 'js',
        meta: {
          './LayoutEditor/Client/*.js': {
              loader: '/LayoutEditor/systemjs-angular-loader.js'
            }
        }
      },
      rxjs: {
        defaultExtension: 'js'
        }

    }
  });
})(this);

我认为问题似乎是转录设置。