我遵循有关Universal的角度教程: https://angular.io/guide/universal
我尝试通过以下方式安装Universal:
ng add @nguniversal/express-engine --clientProject angular.io-example
好吧,运行良好的代码不会返回任何错误。但是它不会像预期的那样生成以下任何文件:
main.server.ts
tsconfig.server.json
app.server.module.ts
server.ts
webpack.server.config.js
这是package.json:
{
"name": "angular-io-example",
"version": "1.0.0",
"private": true,
"description": "Example project from an angular.io guide.",
"scripts": {
"lint": "tslint ./src/**/*.ts -t verbose",
"start": "ng serve",
"test": "ng test",
"build": "ng build --prod",
"e2e": "ng e2e",
"ng": "ng"
},
"keywords": [],
"author": "",
"license": "MIT",
"dependencies": {
"@angular/animations": "^7.1.0",
"@angular/common": "^7.1.0",
"@angular/compiler": "^7.1.0",
"@angular/core": "^7.1.0",
"@angular/forms": "^7.1.0",
"@angular/http": "^7.1.0",
"@angular/platform-browser": "^7.1.0",
"@angular/platform-browser-dynamic": "^7.1.0",
"@angular/router": "^7.1.0",
"@angular/upgrade": "^7.1.0",
"@nguniversal/express-engine": "^7.1.1",
"angular-in-memory-web-api": "github:brandonroberts/in-memory-web-api-bazel#50a34d8",
"core-js": "^2.5.4",
"rxjs": "^6.3.0",
"zone.js": "~0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.11.0",
"@angular/cli": "^7.1.0",
"@angular/compiler-cli": "^7.1.0",
"@angular/platform-server": "^7.1.0",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "^2.0.4",
"@types/node": "~8.9.4",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~3.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"karma-phantomjs-launcher": "^1.0.2",
"lodash": "^4.16.2",
"phantomjs-prebuilt": "^2.1.7",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.11.0",
"typescript": "~3.1.1"
},
"repository": {}
}
那么,文档缺少什么吗?还是我错过了什么?
答案 0 :(得分:3)
经过几次尝试,我尝试更新一些依赖项,这里的问题位于打字稿版本中。将其从typescript: '^3.1.1'
更改为typescript: '^3.2.2'
。然后此命令应该可以正常工作。
ng add @nguniversal/express-engine --clientProject angular.io-example