我试图将现有的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"
}
}
知道我做错了吗?
答案 0 :(得分:1)
通过查看package.json文件中列出的名称,再次检查 version: '3'
services:
db:
image: postgres:9.6
environment:
- ACIM_DATABASE_PASSWORD=ACIM_2018
volumes:
- 'db:/var/lib/postgresql/data'
env_file:
- '.env'
expose:
- '5432'
ports:
- "7000:5432"
nginx:
image: nginx:latest
container_name: production_nginx
volumes:
- ./config/nginx/nginx.conf:/etc/nginx/nginx.conf
- public-content:/var/www/acim/public
ports:
- 80:80
- 443:443
links:
- web
redis:
image: redis
command: redis-server
volumes:
- 'redis:/data'
ports:
- "6379"
sidekiq:
build: .
#command: sidekiq -C config/sidekiq.yml
command: bundle exec sidekiq
volumes:
- .:/ACIM
links:
- db
- redis
depends_on:
- db
- redis
env_file:
- '.env'
web:
build: .
# command: bundle exec rails s -p 3000 -b '0.0.0.0'
volumes:
- bundle_cache:/bundle
- public-content:/var/www/acim/public
- .:/ACIM
ports:
- "5000:3000"
depends_on:
- db
- redis
env_file:
- '.env'
cable:
depends_on:
- 'redis'
build: .
command: puma -p 28080 cable/config.ru
ports:
- '28080:28080'
volumes:
- '.:/ACIM'
env_file:
- '.env'
volumes:
bundle_cache:
redis:
db:
public-content:
是项目的名称。如果名称不是fundercat,则必须在命令中使用该名称才能构建服务器。例如,如果您的项目实际命名为fundercat
,则需要运行FunderCat
来运行服务器。
当我尝试向英雄的角游项目中添加通用角度时,我遇到了类似的问题。文档的措辞方式使其看起来像“我的项目”,这是一种用于运行服务器的特殊角度cli命令。不是。 “我的项目”是指您正在处理的项目的名称。因此,我必须运行ng run FunderCat:server
才能在教程项目中运行服务器,而不是ng run angular-tour-of-heroes:server
。