在angular

时间:2019-01-06 09:06:28

标签: angular angular-universal angular-seo

我正在尝试将我的角度应用转换为角度通用。我不断收到错误消息:

  

在工作区中找不到项目“ my-app”。

当我尝试使用以下方式构建应用程序时:

npm run build:client-and-server-bundles && npm run webpack:server

app.module.ts:

BrowserModule.withServerTransition({appId: 'techstack21-angular'}),

Angular.json:

"server": {
  "builder": "@angular-devkit/build-angular:server",
  "options": {
    "outputPath": "./dist/techstack21-angular",
    "main": "src/main.server.ts",
    "tsConfig": "src/tsconfig.server.json"
  }
},

tsconfig.app.json:

"compilerOptions": {
  "outDir": "../dist/techstack21-angular",
  "module": "es2015",
  "types": ["node"],
  "typeRoots": [
    "node_modules/@types"
  ],
},

Package.json:

 "build:ssr": "npm run build:client-and-server-bundles && npm run webpack:server",
    "serve:ssr": "node dist/server",
    "build:client-and-server-bundles": "ng build --prod && ng run my-app:server",
    "webpack:server": "webpack --config webpack.server.config.js --progress --colors",
    "serve": "node server.js"

我尝试删除node_modules文件夹,但再次遇到相同的错误。该如何解决?

1 个答案:

答案 0 :(得分:1)

您应该在build:client-and-server-bundles脚本中使用自己的项目名称:

package.json

"build:client-and-server-bundles": "ng build --prod && ng run my-app:server",
                                                              ^^^^^^
                                                  replace with your projectName