ng build --prod gives no such file or directory error for the specified outDir in angular-cli.json
当我尝试为prod(ng build --prod)进行构建时,我的角度项目无法构建。 请注意,ng build似乎可以正常工作。
当我尝试使用--prod选项进行构建时,出现以下错误
1 2 3 | 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设置如下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | { "$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设置的相对路径,我希望在myproject / web文件夹下创建一个名为target的文件夹,并且所有构建输出都可在该文件夹中使用。
请让我知道是应该手动创建目标文件夹还是可以告诉angular-cli自动创建目标文件夹的方法?
如代码中所述,您的代码中可能还有其他问题,该问题随后被webpack中的后续异常隐藏了:
https://github.com/angular/angular-cli/issues/7203
那里发生了什么事?构建在编译时失败,因此不会创建您的输出目录,但是CLI仍然执行其他步骤,其中之一(通过webpack提取库许可证)要求输出目录必须存在。该步骤将失败并得到记录,而不是根本原因。
尝试在
我遇到了同样的错误-我试图从dist文件夹中运行命令...当我改回到项目的根文件夹时,然后工作正常
我也遇到了这个问题,我要做的就是将其添加到package.json文件中:
1 2 3 4 | "scripts": { // ... "build":" mkdir dist && ng build --prod" }, |
(假设您的目标文件夹为dist)