Angular-cli 未使用 ng build 生成 dist 目录

use*_*955 8 angular-cli

这是我安装的:

@angular/cli: 1.0.0-rc.1
node: 7.4.0
os: linux x64
@angular/common: 2.4.9
@angular/compiler: 2.4.9
@angular/core: 2.4.9
@angular/forms: 2.4.9
@angular/http: 2.4.9
@angular/platform-browser: 2.4.9
@angular/platform-browser-dynamic: 2.4.9
@angular/router: 3.4.9
@angular/cli: 1.0.0-rc.1
Run Code Online (Sandbox Code Playgroud)

我看过这篇文章Not generated distfolders,但我只想生成一个 dist 目录,以便我可以将它与 Express 链接。我正在使用的命令是

ng build --base-href /apply/
Run Code Online (Sandbox Code Playgroud)

我知道使用 ngserve 文件是在内存中创建的。不过我没有使用 ng 服务。我有一个 Express 静态路径

app.use('/', express.static(path.resolve('../../dist')));
Run Code Online (Sandbox Code Playgroud)

由于构建命令不会创建 dist 目录,我无法为角度应用程序提供服务。链接(上面)中的答案表示使用 --watch 参数。为什么我必须这样做?ng build 不应该创建 dist 目录吗?

我是否遗漏了一些明显的东西?任何帮助表示赞赏。

use*_*955 5

这是我所学到的。没有创建 dist 目录的原因是存在编译错误(在旧的 cli 版本中并非如此)。错误是

ERROR in Error encountered resolving symbol values statically. Only initialized variables and constants can be referenced because the value of this variable is needed by the template compiler (position 79:22 in the original .ts file), resolving symbol AUTH_PROVIDERS in ...
Run Code Online (Sandbox Code Playgroud)

我从 app_module.ts 中删除了 AUTH_PROVIDERS 的依赖项。完成此操作后,项目编译正常。


Nic*_*ter 5

我遇到了同样的问题。我的解决方案是查看文件并从该部分中tsconfig.json删除。然后我运行并生成了文件夹并将其放入项目根目录中。distexcludesng builddist

另请查看您的angular-cli.json文件以查看该outdir字段是否正在写入dist.