我有一个 Angular 项目,最近升级到 Angular 13。该项目是在 Azure DevOps 中构建的。
大约三分之一的构建由于内存问题而失败。每次运行我都会遇到很多不同的错误,但它们都与内存有关。
我已经在互联网上搜索过,并且一直在使用,max_old_space_size
但这似乎并不能解决我的问题。有没有更好的方法可以使角度构建在构建过程中实际使用更少的内存?
以下是我经常看到的 3 个错误。请注意,每次运行都是不同的,有时它构建得很好。
##[error]Error(0,0): Error [main.5aa4446f2024043f.js: ;]DataCloneError: Data cannot be cloned, out of memory.
Error : Optimization error [main.5aa4446f2024043f.js]: DataCloneError: Data cannot be cloned, out of memory. [D:\a\1\s\MyApp\MyApp.Web\MyApp.Web.csproj]
at WorkerInfo.postTask (D:\a\1\s\MyApp\MyApp.Web\ClientApp\node_modules\piscina\dist\src\index.js:305:23)
at ThreadPool._onWorkerAvailable (D:\a\1\s\MyApp\MyApp.Web\ClientApp\node_modules\piscina\dist\src\index.js:518:24)
at D:\a\1\s\MyApp\MyApp.Web\ClientApp\node_modules\piscina\dist\src\index.js:381:46
at AsynchronouslyCreatedResourcePool.maybeAvailable (D:\a\1\s\MyApp\MyApp.Web\ClientApp\node_modules\piscina\dist\src\index.js:237:17)
at WorkerInfo.onMessage (D:\a\1\s\MyApp\MyApp.Web\ClientApp\node_modules\piscina\dist\src\index.js:424:26)
at WorkerInfo._handleResponse (D:\a\1\s\MyApp\MyApp.Web\ClientApp\node_modules\piscina\dist\src\index.js:289:14)
at MessagePort.<anonymous> (D:\a\1\s\MyApp\MyApp.Web\ClientApp\node_modules\piscina\dist\src\index.js:258:51)
at MessagePort.[nodejs.internal.kHybridDispatch] (node:internal/event_target:643:20)
at MessagePort.exports.emitMessage (node:internal/per_context/messageport:23:28)
Run Code Online (Sandbox Code Playgroud)
这里还有另外一个:
#FailureMessage Object: 0000001D9D3F9EB0
#
# Fatal error in , line 0
# Fatal …
Run Code Online (Sandbox Code Playgroud) 我有一个 Angular 应用程序,我试图从应用程序外部(即从 docker compose 文件)设置环境变量。
我指的是下面的文章
https://codinglatte.com/posts/angular/using-os-environment-variables-in-angular-with-docker/
docker-compose.yml
version: '3'
services:
tomcat-server:
image: "tomcat:latest"
ports:
- "8071:8080"
environment:
- API_URL=http://demo-production.com
Run Code Online (Sandbox Code Playgroud)
当我执行以下命令时,我什至可以看到环境变量设置
docker exec -it <dockerName> sh
env
Run Code Online (Sandbox Code Playgroud)
但不知何故,Angular 应用程序没有收到该值,下面是我的 Angular 应用程序代码,按照上面的文章
环境.产品.ts
export const environment = {
production: true,
API_URL: $ENV.API_URL,
TEST_ENV: 'testing'
// API_URL: 'http://production.com'
};
Run Code Online (Sandbox Code Playgroud)
打字.d.ts
declare var $ENV: Env;
interface Env {
API_URL: string
}
Run Code Online (Sandbox Code Playgroud)
自定义-webpack.config.js
const webpack = require('webpack');
module.exports = {
plugins: [
new webpack.DefinePlugin({
$ENV: {
API_URL: JSON.stringify(process.env.API_URL)
}
})
]
};
Run Code Online (Sandbox Code Playgroud)
我用来创建构建的命令 …
当我跑步时ng build
我得到,
\xe2\x9d\xaf ng build\nBuilding Angular Package\nConfiguration doesn't match the required schema.\nData path "/lib" must NOT have additional properties (umdModuleIds).\n
Run Code Online (Sandbox Code Playgroud)\n这个问题的根源是什么以及如何解决它
\n使用以下命令升级到 Angular 12ng update @angular/core@12 @angular/cli@12
会导致我在使用该模式编译时出现以下错误--configuration production
。
\xe2\x9c\x96 Index html generation failed.\nundefined:15:4027680: missing \'}\'\n
Run Code Online (Sandbox Code Playgroud)\n这是这个问题的重复,但想发布一个正确的问题/答案,因为它肯定会帮助其他人,而且我不知道我们什么时候能够在该线程上再次发布,因为它几天前就关闭了
\n