按照离子文档,我尝试在Ionic 4中创建一个简单的 multi-apps项目,但是它不起作用。
https://ionicframework.com/docs/cli/configuration#multi-app-projects
我的配置:
我做了什么: 我创建了一个目录“ monorepo”。 在此文件夹中,我创建了文件ionic.config.json并粘贴了以下代码:
{
"projects": {}
}
在monorepo中,我创建了另一个目录:apps。 在此目录中(带有命令提示符),我编写命令: 离子启动“ app1”-不滴水
monorepo / ionic.config.json已正确填充数据:
{
"projects": {
"app1": {
"name": "app1",
"integrations": {},
"type": "angular",
"root": "apps\\app1"
}
}
}
但是当我尝试为服务器提供服务时,它将无法正常工作。
ionic serve --project app1
返回此错误消息:
> ng run app1:serve --host=0.0.0.0 --port=8100
[ng] Project 'app1' could not be found in workspace.
[ng] Error: Project 'app1' could not be found in workspace.
[ng] at Workspace.getProject (C:\Users\name\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\@angular-devkit\core\src\workspace\workspace.js:93:19)
[ng] at Architect.getBuilderConfiguration (C:\Users\name\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\@angular-devkit\architect\src\architect-legacy.js:117:41)
[ng] at RunCommand.runSingleTarget (C:\Users\name\AppData\Roaming\npm\node_modules\@angular\cli\models\architect-command.js:160:45)
[ng] at RunCommand.runArchitectTarget (C:\Users\name\AppData\Roaming\npm\node_modules\@angular\cli\models\architect-command.js:201:35)
[ng] at RunCommand.run (C:\Users\name\AppData\Roaming\npm\node_modules\@angular\cli\commands\run-impl.js:14:25)
[ng] at RunCommand.validateAndRun (C:\Users\name\AppData\Roaming\npm\node_modules\@angular\cli\models\command.js:124:31)
[ng] at process._tickCallback (internal/process/next_tick.js:68:7)
[ng] at Function.Module.runMain (internal/modules/cjs/loader.js:745:11)
[ng] at startup (internal/bootstrap/node.js:283:19)
[ng] at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)
[ERROR] ng has unexpectedly closed (exit code 1).
The Ionic CLI will exit. Please check any output above for error details.
当我进入与错误相关的文件(workspace.js:93:19),并且执行console.log时,我会获得以下信息:
getProject(projectName) {
this._assertLoaded();
console.log("this.projectName : " + projectName); // this.projectName : app1
console.log("\n\nthis._workspace.projects : \n");
console.log(this._workspace.projects); // this._workspace.projects : app and app-e2e
const workspaceProject = this._workspace.projects[projectName];
(显示的值在注释中)。
projectName变量似乎没问题。但是this._workspace.projects
中可用的项目是app和app-e2e,看起来很奇怪。
我的问题是什么? 我想念什么?
答案 0 :(得分:0)
我设法通过将每个Query selectQuery = session.createQuery("SELECT g FROM UrllinkEntity as g ");
selectQuery.setFirstResult((lastPageNumber - 1) * pageSize);
关键字中的angular.json
替换为离子项目的名称(此处为app
)来进行编译。
app1
我想,应该将每个离子项目的{
"$schema": "./node_modules/@angular-devkit/core/src/workspace/workspace-schema.json",
"version": 1,
"defaultProject": "app1", <-- HERE
"newProjectRoot": "projects",
"projects": {
"app1": { <-- HERE
"root": "",
"sourceRoot": "src",
"projectType": "application",
"prefix": "app1", <-- NOT MANDATORY
"schematics": {},
"architect": {
"build": { ... },
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "app1:build" <-- HERE
},
...
}