我目前正在尝试测试ng build --watch函数来编辑我的角度视图,而无需手动构建它。
启动它时没有任何错误,但是当我尝试访问我的网站时,控制台上出现了那些错误(Firefox和Chrome上的不同错误)
Chrome: 未捕获的TypeError:无法读取未定义的属性“调用”
Firefox: TypeError:modules [moduleId]未定义
经过研究后,问题是相同的,并且位于引导文件中:这是一段代码:
function __webpack_require__(moduleId) {
// Check if module is in cache
if(installedModules[moduleId]) {
return installedModules[moduleId].exports;
}
// Create a new module (and put it into the cache)
var module = installedModules[moduleId] = {
i: moduleId,
l: false,
exports: {}
};
// Execute the module function
modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
// Flag the module as loaded
module.l = true;
// Return the exports of the module
return module.exports;
}
我对这个世界很陌生,您对我在做什么错有任何想法吗? (我尝试清空浏览器缓存,但没有成功)。如果您需要有关该项目的更多信息,我可以为您提供所需的信息
编辑:当我运行ng build --prod时,一切正常。
答案 0 :(得分:0)
这通常是因为默认情况下动态插入的脚本是异步的。您必须使用script.async = false
明确禁用它。
请参阅此文章:https://swizec.com/blog/arcane-javascript-knowledge-still-useful/swizec/7932