【问题标题】:NgModule is not a functionNgModule 不是函数
【发布时间】:2016-08-22 22:56:53
【问题描述】:

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

Error: TypeError: s.NgModule is not a function(…)

在我的基于 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"
  }
}

【问题讨论】:

    标签: angular angular2-upgrade


    【解决方案1】:

    如果我错了,请纠正我。

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

    【讨论】:

    • 是的,我使用的是 "ng2-translate": "^2.1.0",它引入了 RC5 依赖项 - 更改为固定版本 "2.2.2" 只需要 RC4 并暂时解决了我的问题,虽然我需要适时升级。
    【解决方案2】:

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

    "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”。

    【讨论】:

    • 感谢博彦 - 更改为“ng2-translate”:“2.2.2”,已修复 :-)
    • 太棒了!就这么简单,我很高兴!
    猜你喜欢
    • 2017-01-27
    • 1970-01-01
    • 2020-08-20
    • 2017-05-31
    • 2022-11-10
    • 2022-11-26
    • 1970-01-01
    • 2019-09-20
    • 2018-01-18
    相关资源
    最近更新 更多