编译angular时报ERROR in wpl010144/wpl010144.js?v=20aa9887331f3a0ffb3e from UglifyJs Error: error:0308010C:digital envelope routines::unsupported
时间: 2024-04-13 16:23:40 浏览: 181
这个错误是由于UglifyJs不支持某些ES6语法导致的。你可以尝试以下方法解决这个问题:
1. 升级你的Node.js版本到最新的LTS版本,确保它支持ES6语法。
2. 在你的`tsconfig.json`文件中,将`target`属性设置为`"es5"`,以确保TypeScript编译器生成的JavaScript代码是ES5兼容的。
3. 如果你使用的是Angular CLI,可以尝试在`angular.json`文件中添加以下配置:
```json
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/your-project-name",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.app.json",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.css"
],
"scripts": []
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb",
"maximumError": "10kb"
}
]
}
}
}
}
```
4. 如果以上方法都无法解决问题,你可以考虑使用其他压缩工具,如Terser,替换UglifyJs。
阅读全文