2017-03-02 69 views
1

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

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

ERROR in [default]/Users/Desktop/Project/directory/node_modules/@types/jasmine/index.d.ts:39:51 '='预计。

ERROR in [default] /Users/Desktop/directory/node_modules/@types/lodash/index.d.ts:244:12 重复的标识符'_'。

ERROR in [default]/Users/Desktop/Project/directory/node_modules/@types/lodash/index.d.ts:244:15 找不到命名空间'_'。

ERROR in [default]/Users/Desktop/Project/directory/node_modules/@types/lodash/index.d.ts:246:24 找不到名称'Partial'。

ERROR in [default]/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 

新的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); 
+0

如果您还有** typings **文件夹,请将其删除。 –

+0

我在哪里可以找到typings文件夹,你的意思是typings.d.ts? – Switz

+0

那么,如果你不能在你的应用程序主文件夹中看到它,这意味着没有typings文件夹。 –

回答

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' 
     } 
} 

这不是我的意图,而是将其作为答案添加,但对于评论太多了。

+0

我仍然在控制台中出现相同的错误 – Switz

+1

您的服务器正在从您的main.ts文件和您的node_modules文件夹正确的相同文件夹运行吗? –

+0

是的,即使我已经更新了软件包 – Switz