【发布时间】:2018-06-05 18:07:30
【问题描述】:
我有一个奇怪的错误。我有一个使用 angularJS 模块或 angular 5 模块的 Angular 应用程序。
我使用 @angular/cli@1.7.4 + npm version 5.6.0 编译我的代码,如果我运行 cmd ng build --prod --output-hashing none --aot false 我没有收到任何错误并且应用程序运行良好,但是如果我运行命令 gulp predebug && ng build --app=app_debug --watch --preserve-symlinks 我得到以下错误:
Uncaught TypeError: Cannot read property 'module' of undefined
at Object../src/app/app.module.ts (app.module.ts:147)
at __webpack_require__ (bootstrap 53b81b2588e9ef027265:54)
at Object../src/main.ts (main.ts:4)
at __webpack_require__ (bootstrap 53b81b2588e9ef027265:54)
at Object.0 (main.ts:11)
at __webpack_require__ (bootstrap 53b81b2588e9ef027265:54)
at webpackJsonpCallback (bootstrap 53b81b2588e9ef027265:25)
at main.bundle.js:1
以下是我的代码摘录:
import angular from '@primavera/corejs/ng/angular';
....
angular.module('angular2', [
angularresource,
angularsanitize,
angularanimate,
uirouter,
uibootstrap]);
注意事项:
- 浏览器控制台出现错误
- 如果我将 angular/cli 版本降级到 1.5.0 可以正常运行命令
gulp predebug && ng build --app=app_debug --watch --preserve-symlinks但ng build --prod --output-hashing none --aot false无法运行并向 npm 控制台抛出一些错误。
我已经在 this 和 this 看到问题的根源可能是 cli 的版本,但即使降级到版本 1.6.8 也不起作用。
感谢您的帮助。
【问题讨论】:
标签: angularjs angular angular-cli