我正在尝试将我的Angular项目转换为与Angular Universal(https://universal.angular.io/)兼容。我正在按照此教程进行操作:https://github.com/angular/angular-cli/wiki/stories-universal-rendering。我卡在第3步的末尾(构建包)。我的项目名称是"fundercat"。当我尝试运行时:
ng run fundercat:server
我收到了错误信息:
Project 'dist/fundercat' could not be found in workspace.
按照教程,我修改了app.module.ts中的以下行:
@NgModule({
imports: [
// Modified this line:
BrowserModule.withServerTransition({appId: 'fundercat'}),
我在 angular.json 文件中添加了以下内容:
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"fundercat": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"architect": {
...
// added this block:
"server": {
"builder": "@angular-devkit/build-angular:server",
"options": {
"outputPath": "dist/fundercat",
"main": "src/main.server.ts",
"tsConfig": "src/tsconfig.server.json"
}
}
有什么想法是我做错了吗?
"outputPath": "dist/server"
这段代码吗? - Fateme Fazli"outputPath": "dist/your-project-name-server",
,因此我将其设置为"outputPath": "dist/fundercat",
。 - americanknight