angular - Angular 6 在“e2e/app”文件夹中生成服务
问题描述
我最近将我的角度 4 升级到 6。现在我尝试了以下命令
ng generate service security/security
但它在文件夹“e2e/app”下创建了服务,而不是在下面的“src/app”下是我的 angular.json
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"xyz": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist",
"index": "src/index.html",
"main": "src/main.ts",
"tsConfig": "src/tsconfig.app.json",
"polyfills": "src/polyfills.ts",
"assets": [
"src/assets",
"src/favicon.ico"
],
"styles": [
"node_modules/bootstrap/dist/css/bootstrap.min.css",
"src/style.scss",
"src/styles.css"
],
"scripts": [
]
},
"configurations": {
"production": {
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
]
},
"test": {
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.test.ts"
}
]
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "xyz:build"
},
"configurations": {
"production": {
"browserTarget": "xyz:build:production"
},
"test": {
"browserTarget": "xyz:build:test"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "xyz:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"karmaConfig": "./karma.conf.js",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"scripts": [
"node_modules/jquery/dist/jquery.min.js",
"node_modules/tether/dist/js/tether.min.js",
"node_modules/bootstrap/dist/js/bootstrap.min.js"
],
"styles": [
"node_modules/bootstrap/dist/css/bootstrap.min.css",
"src/style.scss",
"src/styles.css"
],
"assets": [
"src/assets",
"src/favicon.ico"
]
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"src/tsconfig.app.json",
"src/tsconfig.spec.json"
],
"exclude": []
}
}
}
},
"xyz-e2e": {
"root": "",
"sourceRoot": "e2e",
"projectType": "application",
"architect": {
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "./protractor.conf.js",
"devServerTarget": "xyz:serve"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"e2e/tsconfig.e2e.json"
],
"exclude": []
}
}
}
}
},
"defaultProject": "xyz",
"schematics": {
"@schematics/angular:component": {
"prefix": "app",
"styleext": "css"
},
"@schematics/angular:directive": {
"prefix": "app"
}
}
}
我最近从 angular 4 升级到 6,当我尝试使用 angular-cli ne new my-app 命令创建的新应用程序时,它在 src/app 文件夹中正确创建
解决方案
在angular.json
文件中,搜索: my-project-e2e
替换my-project
为您的项目名称。
改变:
"root": "" to "root": "e2e"
我在这里找到了它,它对我有用。
推荐阅读
- php - PHP get_file_contents() 函数超时
- javascript - 在嵌套手风琴中访问父手风琴
- python - 函数没有返回正确的值
- javascript - 我的滚动到顶部不流畅
- html - 饼图响应硬编码数据
- css - 全宽网页视图 Reactvr
- azure-devops - 在 VSTS 中使用“小时”进行估计
- wordpress - ReactJS fetch() api 调用返回 null 或空数组
- vba - VBA Word 为什么.BaseStyle 不保持大写?
- node.js - nodejs express mongoose - 试图将列表的长度作为模型中的虚拟参数作为响应