angular_1.default.module未捕获的TypeError:无法读取未定义的属性'module'

Sau*_*hra 3 angularjs typescript gulp webpack

我正在使用angular 1.6,webpack,gulp和Typescript创建一个入门模板。我可以编译和构建我的应用程序,但是应用程序无法启动。这个问题很奇怪,当我调试的angular.module定义和模块可以从控制台创建angular.module('testModule', []),但因为简历调试我得到异常core.module.tsexport const CoreModule = angular.module('app.core', []).name;

我通过禁用源代码进一步研究了此问题,并且发现了问题。上面提到的代码编译到在angular_1上exports.CoreModule = angular_1.default.module('app.core', []).name;没有命名属性的地方default。有关代码,请参阅https://github.com/muditsaurabh/awesome-ng-starter

Uncaught TypeError: Cannot read property 'module' of undefined
    at Object.<anonymous> (app.bundle.js?cd4d443…:1)
    at e (vendor.bundle.js?cd4d443…:1)
    at Object.<anonymous> (app.bundle.js?cd4d443…:1)
    at e (vendor.bundle.js?cd4d443…:1)
    at Object.<anonymous> (app.bundle.js?cd4d443…:1)
    at e (vendor.bundle.js?cd4d443…:1)
    at window.webpackJsonp (vendor.bundle.js?cd4d443…:1)
    at app.bundle.js?cd4d443…:1
vendor.bundle.js?cd4d443…:6Uncaught Error: [$injector:modulerr] Failed to instantiate module app due to:
Error: [$injector:nomod] Module 'app' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
http://errors.angularjs.org/1.6.1/$injector/nomod?p0=app
    at http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:377
    at http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:11230
    at n (http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:10668)
    at http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:11004
    at http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:20796
    at r (http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:809)
    at h (http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:20644)
    at le (http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:22631)
    at a (http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:8560)
    at st (http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:8870)
http://errors.angularjs.org/1.6.1/$injector/modulerr?p0=app&p1=Error%3A%20%…2F%2Flocalhost%3A8000%2Fvendor.bundle.js%3Fcd4d4432605c6f5be56a%3A6%3A8870)
    at http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:377
    at http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:11230
    at n (http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:10668)
    at http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:11004
    at http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:20796
    at r (http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:809)
    at h (http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:20644)
    at le (http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:22631)
    at a (http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:8560)
    at st (http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:8870)
http://errors.angularjs.org/1.6.1/$injector/modulerr?p0=app&p1=Error%3A%20%…2F%2Flocalhost%3A8000%2Fvendor.bundle.js%3Fcd4d4432605c6f5be56a%3A6%3A8870)
    at http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:377
    at http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:21073
    at r (http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:809)
    at h (http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:20644)
    at le (http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:22631)
    at a (http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:8560)
    at st (http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:8870)
    at at (http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:8109)
    at http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:11:13916
    at HTMLDocument.n (http://localhost:8000/vendor.bundle.js?cd4d4432605c6f5be56a:6:17809)
Run Code Online (Sandbox Code Playgroud)

Sau*_*hra 5

我已替换import angular from 'angular'import * as angular from 'angular',现在工作正常。