我正在尝试将我的角度应用程序转换为角度通用。我不断收到错误说:
在工作区中找不到项目"我的应用程序"。
当我尝试使用以下方法构建应用程序时:
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
文件夹,但再次收到相同的错误。如何解决这个问题?
您应该build:client-and-server-bundles
脚本中使用自己的项目名称:
包.json
"build:client-and-server-bundles": "ng build --prod && ng run my-app:server",
^^^^^^
replace with your projectName