gpt4 book ai didi

angular - ng build --prod 没有为 angular-cli.json 中指定的 outDir 提供此类文件或目录错误

转载 作者:行者123 更新时间:2023-12-04 02:02:58 25 4
gpt4 key购买 nike

当我尝试为 prod 构建时,我的 angular 项目无法构建( ng build --prod )。请注意 ng build 似乎工作正常。

当我尝试使用 --prod 选项构建时出现以下错误

Error: ENOENT: no such file or directory, mkdir 'C:\dev\workspaces\intellij-workspaces\myproject\web\target\frontend'
at Error (native)
at Object.fs.mkdirSync (fs.js:922:18)

我已将我的 angular-cli outDir 设置为如下
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"project": {
"name": "web"
},
"apps": [
{
"root": "src",
"outDir": "../../../target/frontend",
"deployUrl": "myproject-dashboard/",
"assets": [
"assets",
"favicon.ico"
],

我的 package.json 和 angular-cli.json 文件存在于
myproject/web/src/main/frontend

因此,理想情况下,基于 angular-cli.json 中为 outDir 设置的相对路径,我希望在 下创建一个名为 target 的文件夹。我的项目/网站 文件夹和我所有的构建输出都在那里可用。

请您告诉我是否应该手动创建目标文件夹,还是有办法告诉 angular-cli 自动创建它?

最佳答案

很可能您的代码中存在一些其他问题,这些问题被 webpack 的后续异常隐藏了,如这张票中所述:

https://github.com/angular/angular-cli/issues/7203

那里发生什么事了? Build 在编译时失败,因此不会创建您的输出目录,但随后 CLI 仍会执行其他步骤,其中之一(通过 webpack 提取库许可证)要求输出目录应存在。该步骤失败并被记录而不是根本原因。

尝试添加 --no-extract-licenses您的 ng build -prod 的选项命令。这对我有用,错误与您的情况完全相同。

关于angular - ng build --prod 没有为 angular-cli.json 中指定的 outDir 提供此类文件或目录错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46077766/

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