NgModule不是一个函数

时间:2016-08-22 22:56:53

标签: angular angular2-upgrade

截至2016年8月19日星期五,我开始收到运行时javascript控制台错误:

错误:TypeError:s.NgModule不是函数(...)

在我的基于RC4的应用程序中。我还没有尝试更新到RC5,所以我希望我的基于RC4的代码仍然可以按照文档进行操作。我的package.json是(有点匿名):

    {
  "name": "xxxxxxxxxx",
  "version": "2.0.0",
  "description": "xxxxxxxxxxxxxxxxxyyyyyyyyy",
  "scripts": {
    "start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\" ",
    "lite": "node server.js --lifecycle=lcl",
    "postinstall": "typings install",
    "tsc": "tsc",
    "tsc:w": "tsc -w",
    "typings": "typings"
  },
  "author": "xxxxxxxxxxxxxxxxx",
  "dependencies": {
    "@angular/common": "2.0.0-rc.4",
    "@angular/compiler": "2.0.0-rc.4",
    "@angular/core": "2.0.0-rc.4",
    "@angular/http": "2.0.0-rc.4",
    "@angular/platform-browser": "2.0.0-rc.4",
    "@angular/platform-browser-dynamic": "2.0.0-rc.4",
    "@angular/router": "3.0.0-beta.2",
    "@angular/upgrade": "2.0.0-rc.4",
    "@angular/forms": "0.2.0",
    "xyzco-bootstrap-custom": "git+ssh://git@gitscm.xyzco.com/asf/xyzco-bootstrap-custom.git",
    "core-js": "2.4.1",
    "jquery": "^3.1.0",
    "ng2-bootstrap": "^1.0.24",
    "ng2-redux": "^3.3.0",
    "ng2-translate": "^2.1.0",
    "redux": "^3.5.2",
    "redux-thunk": "^2.1.0",
    "reflect-metadata": "^0.1.3",
    "rxjs": "5.0.0-beta.6",
    "systemjs": "0.19.27",
    "zone.js": "^0.6.12"
  },
  "devDependencies": {
    "body-parser": "^1.15.2",
    "concurrently": "^2.0.0",
    "del": "^2.2.1",
    "express": "^4.14.0",
    "gulp": "^3.9.1",
    "gulp-clean-css": "^2.0.11",
    "gulp-concat": "^2.6.0",
    "gulp-inline-ng2-template": "^2.1.0",
    "gulp-jspm-build": "0.0.15",
    "gulp-rename": "^1.2.2",
    "gulp-sass": "^2.3.2",
    "gulp-sequence": "^0.4.5",
    "gulp-traceur": "^0.17.2",
    "gulp-typescript": "^2.13.6",
    "gulp-uglify": "^1.5.4",
    "helmet": "^2.1.1",
    "lite-server": "^2.2.0",
    "mongojs": "^2.4.0",
    "sql-injection": "0.0.5",
    "systemjs-builder": "^0.15.23",
    "typescript": "^1.8.10",
    "typings": "^1.3.2"
  }
}

2 个答案:

答案 0 :(得分:3)

如果我错了,请纠正我。

我相信NgModule是RC5的功能。您可能需要将angular 2应用程序更新为RC5。

答案 1 :(得分:0)

这意味着您的某个软件包已升级,需要RC5版本的Angular 2.请查看以下内容之一:

"ng2-bootstrap": "^1.0.24",
"ng2-redux": "^3.3.0",
"ng2-translate": "^2.1.0",
"redux": "^3.5.2",
"redux-thunk": "^2.1.0",

包号前面的^至少表示该版本,但如果有更高版本可用,它将升级到它。解决方法是删除“^”,删除“node_modules”目录并再次执行“npm install”。