更新Angular 2

时间:2017-03-02 20:16:10

标签: angular

更新我的package.json后,我收到以下错误。我很确定它来自node_modules文件夹。当我运行应用程序时,它像以前一样工作正常但webpack:无法编译。我该怎么做才能解决这个问题?

  

[默认] /用户/桌面/中的错误   Project/directory/node_modules/@types/jasmine/index.d.ts:39:45       找不到名称' keyof'。

     

错误在[默认] / Users / Desktop / Project/directory/node_modules/@types/jasmine/index.d.ts:39:51       ' ='预期

     

[默认]中的错误/Users/Desktop/directory/node_modules/@types/lodash/index.d.ts:244:12    标识符重复' _'。

     

错误在[默认] / Users / Desktop / Project/directory/node_modules/@types/lodash/index.d.ts:244:15       找不到命名空间' _'。

     

错误在[默认] / Users / Desktop / Project/directory/node_modules/@types/lodash/index.d.ts:246:24       找不到姓名'部分'。

     

错误在[默认] / Users / Desktop / Project/directory/node_modules/@types/lodash/index.d.ts:248:18       标识符重复' _'。

 //new error
GET http://localhost:4200/node_modules/zone.js/dist/zone.js 
localhost/:11 GET http://localhost:4200/node_modules/primeng/resources/themes/omega/theme.css 
localhost/:18 GET http://localhost:4200/node_modules/primeng/resources/primeng.min.css 
localhost/:24 GET http://localhost:4200/node_modules/core-js/client/shim.min.js 
localhost/:26 GET http://localhost:4200/node_modules/reflect-metadata/Reflect.js 
localhost/:27 GET http://localhost:4200/systemjs.config.js 
(index):11 GET http://localhost:4200/node_modules/primeng/resources/themes/omega/theme.css 
(index):18 GET http://localhost:4200/node_modules/primeng/resources/primeng.min.css 
(index):21 GET http://localhost:4200/node_modules/primeng/resources/themes/omega/theme.css 
(index):24 GET http://localhost:4200/node_modules/core-js/client/shim.min.js 
(index):25 GET http://localhost:4200/node_modules/zone.js/dist/zone.js 
(index):26 GET http://localhost:4200/node_modules/reflect-metadata/Reflect.js 
(index):27 GET http://localhost:4200/systemjs.config.js  

new package.json

    {
      "name": "directory",
      "version": "0.0.0",
      "license": "MIT",
      "angular-cli": {},
      "scripts": {
        "start": "ng serve",
        "lint": "tslint \"src/**/*.ts\"",
        "test": "ng test",
        "pree2e": "webdriver-manager update",
        "e2e": "protractor"
      },
      "private": true,
      "dependencies": {
        "@angular/common": "~2.4.9",
        "@angular/compiler": "~2.4.9",
        "@angular/core": "~2.4.9",
        "@angular/forms": "~2.4.9",
        "@angular/http": "~2.4.9",
        "@angular/platform-browser": "~2.4.9",
        "@angular/platform-browser-dynamic": "~2.4.9",
        "@angular/router": "~3.4.9",
        "@types/lodash": "^4.14.50",
        "angular-2-data-table": "^0.1.2",
        "angular2-datatable": "^0.5.2",
        "core-js": "^2.4.1",
        "lodash": "^4.17.4",
        "ng2-date-picker": "^0.2.1",
        "ng2-file-upload": "^1.1.2",
        "ng2-modal": "0.0.25",
        "ng2-pagination": "^2.0.1",
        "ng2-table": "^1.3.2",
        "primeng": "^2.0.1",
        "rxjs": "5.2.0",
        "tinymce": "^4.5.2",
        "ts-helpers": "^1.1.1",
        "zone.js": "^0.7.7"
      },
      "devDependencies": {
        "@types/jasmine": "^2.2.30",
        "@types/node": "^7.0.5",
        "angular-cli": "1.0.0-beta.28.3",
        "codelyzer": "3.0.0-beta.0",
        "jasmine-core": "2.5.2",
        "jasmine-spec-reporter": "3.2.0",
        "karma": "1.5.0",
        "karma-chrome-launcher": "^2.0.0",
        "karma-cli": "^1.0.1",
        "karma-jasmine": "^1.0.2",
        "karma-remap-istanbul": "^0.6.0",
        "protractor": "5.1.1",
        "ts-node": "2.1.0",
        "tslint": "4.5.1",
        "typescript": "~2.2.1"
      }
    }

旧的package.json

{
  "name": "directory",
  "version": "0.0.0",
  "license": "MIT",
  "angular-cli": {},
  "scripts": {
    "start": "ng serve",
    "lint": "tslint \"src/**/*.ts\"",
    "test": "ng test",
    "pree2e": "webdriver-manager update",
    "e2e": "protractor"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "~2.1.0",
    "@angular/compiler": "~2.1.0",
    "@angular/core": "~2.1.0",
    "@angular/forms": "~2.1.0",
    "@angular/http": "~2.1.0",
    "@angular/platform-browser": "~2.1.0",
    "@angular/platform-browser-dynamic": "~2.1.0",
    "@angular/router": "~3.1.0",
    "@types/lodash": "^4.14.50",
    "angular-2-data-table": "^0.1.2",
    "angular2-datatable": "^0.5.2",
    "core-js": "^2.4.1",
    "lodash": "^4.17.4",
    "ng2-date-picker": "^0.2.1",
    "ng2-file-upload": "^1.1.2",
    "ng2-modal": "0.0.24",
    "ng2-pagination": "^2.0.1",
    "ng2-table": "^1.3.2",
    "primeng": "^1.1.4",
    "rxjs": "5.0.0-beta.12",
    "tinymce": "^4.5.2",
    "ts-helpers": "^1.1.1",
    "zone.js": "^0.6.23"
  },
  "devDependencies": {
    "@types/jasmine": "^2.2.30",
    "@types/node": "^6.0.42",
    "angular-cli": "1.0.0-beta.18",
    "codelyzer": "1.0.0-beta.1",
    "jasmine-core": "2.4.1",
    "jasmine-spec-reporter": "2.5.0",
    "karma": "1.2.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.0.2",
    "karma-remap-istanbul": "^0.2.1",
    "protractor": "4.0.9",
    "ts-node": "1.2.1",
    "tslint": "3.13.0",
    "typescript": "~2.0.3"
  }
}
//system.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: {
      "ng2-modal": "node_modules/ng2-modal",
        "ng2-ckeditor": "npm:ng2-ckeditor",



        // 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/compiler': 'npm:@angular/compiler/bundles/compiler.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/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/upgrade': 'npm:@angular/upgrade/bundles/upgrade.umd.js',
        'primeng':                   'npm:primeng',

        // other libraries
      'rxjs':                      'npm:rxjs',
      'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js',
      'ng2-pagination': 'npm:ng2-pagination' // add mapping for ng2-pagination

    },
    // packages tells the System loader how to load when no filename and/or no extension
    packages: {
        "ng2-ckeditor": {

            "ng2-modal": {"main": "index.js", "defaultExtension": "js"},
            app: {
                main: './main.js',
                defaultExtension: 'js'
            },
        },
        'ng2-pagination': { //add configuration to load
        main: './index.js',
        defaultExtension: 'js'
      },
      rxjs: {
        defaultExtension: 'js'
      }
    }
  });
})(this);

1 个答案:

答案 0 :(得分:0)

好了,在阅读完该配置代码后,您可以看到放置app软件包的位置,将package条目替换为此条目:

packages: {
      /*"ng2-ckeditor": {        
        main: './index.js',
        defaultExtension: 'js'      
      },*/
      "ng2-modal": {
        defaultExtension: "js"
      },
      'ng2-pagination': { //add configuration to load
        defaultExtension: 'js'
      },
      primeng: {
        defaultExtension: 'js'
      }
      rxjs: {
        defaultExtension: 'js'
      },
      app: {
        main: './main.js',
        defaultExtension: 'js'
      }
}

我不打算将此作为答案添加,但这对于评论来说太过分了。