gpt4 book ai didi

angularjs - angular_1.default.module 未捕获类型错误 : Cannot read property 'module' of undefined

转载 作者:搜寻专家 更新时间:2023-10-30 21:04:42 25 4
gpt4 key购买 nike

我正在使用 angular 1.6、webpack、gulp 和 typescript 创建一个入门模板。我能够编译和构建我的应用程序,但应用程序未启动。这个问题很奇怪,因为当我调试时定义了 angular.module 并且可以从控制台 angular.module('testModule', []) 创建模块但是作为恢复调试器我在 export const CoreModule = angular.module('app.core', []).name;.

core.module.ts 中得到异常

我通过禁用源代码进一步调查了这个问题,并找到了问题所在。上面提到的代码编译为 exports.CoreModule = angular_1.default.module('app.core', []).name; 其中没有名为 default 的属性 Angular _1。有关代码,请参阅 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)

最佳答案

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

关于angularjs - angular_1.default.module 未捕获类型错误 : Cannot read property 'module' of undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41441642/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com