由于项目范围的原因,我试图在旧版本的浏览器中运行我的Angular应用程序。应用程序在最新版本和Chrome中运行良好。似乎问题是IE10和Mozilla Firefox(Firefox版本< 50)。我正在使用48.0.1运行我的应用程序,并且我在控制台中看到简单的单行问题。
TypeError:这是未定义的那就是它。
我尝试谷歌并发现了一个类似的git hub问题。
这是我找到的关闭解决方案。 https://github.com/angular/angular-cli/issues/9340
我尝试按照与uglifyjs-webpack-plugin相关的问题执行步骤,并将其移至以前的1.1.5版本。我也尝试过这些命令。
npm i uglifyjs-webpack-plugin@1.1.5 --save-exact
rm -rf package-lock.json node_modules
npm install
现在问题是我仍然可以在package-lock.json文件中看到其他版本的1.2.5和0.4.6。我手动删除了但仍无解决方案。
的package.json
"dependencies": {
...
"uglifyjs-webpack-plugin": "1.1.5",
}
包lock.json
"@angular/cli": {
"dependencies": {
"requires": {
...
"uglifyjs-webpack-plugin": "1.2.5",
}
"uglifyjs-webpack-plugin": {
"version": "1.2.5",
"resolved": "https://registry.npmjs.org/uglifyjs-webpack-plugin/-/uglifyjs-webpack-plugin-1.2.5.tgz",
"integrity": "sha512-hIQJ1yxAPhEA2yW/i7Fr+SXZVMp+VEI3d42RTHBgQd2yhp/1UdBcR3QEWPV5ahBxlqQDMEMTuTEvDHSFINfwSw==",
"dev": true,
"requires": {
"cacache": "10.0.4",
"find-cache-dir": "1.0.0",
"schema-utils": "0.4.5",
"serialize-javascript": "1.5.0",
"source-map": "0.6.1",
"uglify-es": "3.3.9",
"webpack-sources": "1.1.0",
"worker-farm": "1.6.0"
},
"dependencies": {
"source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
"dev": true
}
}
}
....
"uglifyjs-webpack-plugin": {
"version": "1.1.5",
"resolved": "https://registry.npmjs.org/uglifyjs-webpack-plugin/-/uglifyjs-webpack-plugin-1.1.5.tgz",
"integrity": "sha512-YBGc9G7dv12Vjx8vUQs54DZgAXVf04LlG6dNNiEbTZjL3PbUqiY4uPB9Kv+fUJaqRskEGva/lS7sh08yJr7jnA==",
"requires": {
"cacache": "10.0.4",
"find-cache-dir": "1.0.0",
"schema-utils": "0.3.0",
"serialize-javascript": "1.5.0",
"source-map": "0.6.1",
"uglify-es": "3.2.2",
"webpack-sources": "1.1.0",
"worker-farm": "1.6.0"
}
},
"webpack": {
"requires": {
"uglifyjs-webpack-plugin": "0.4.6",
}
"dependencies": {
"uglifyjs-webpack-plugin": {
"version": "0.4.6",
"resolved": "https://registry.npmjs.org/uglifyjs-webpack-plugin/-/uglifyjs-webpack-plugin-0.4.6.tgz",
"integrity": "sha1-uVH0q7a9YX5m9j64kUmOORdj4wk=",
"dev": true,
"requires": {
"source-map": "0.5.7",
"uglify-js": "2.8.29",
"webpack-sources": "1.1.0"
}
},
}
}
}
}
我能得到任何想法或帮助。这对项目而言至关重要。
提前致谢。
答案 0 :(得分:0)
我找到了可用的解决方法。
只需添加--aot false即可。
我正在使用命令 ng serve --prod --aot = false ,它就像魅力一样。
但有什么想法是否安全?我发现了同样的github讨论。
https://github.com/angular/angular-cli/issues/9244
https://github.com/angular/angular/issues/21631
强烈建议您对此问题或正确答案进行更新。
谢谢,