确保angular.json 中的项目名称与package.json 脚本部分中调用的名称相匹配。
这就是我发现问题的方式。我收到以下错误:
An unhandled exception occurred: Project does not exist.
See "C:\Users\Adam\AppData\Local\Temp\ng-XcQsPs\angular-errors.log" for further details.
当我访问那个日志文件时,我看到了这个:
[error] Error: Project does not exist.
at WorkspaceNodeModulesArchitectHost.findProjectTarget (C:\Users\Adam\source\repos\TechScore.Express\node_modules\@angular-devkit\architect\node\node-modules-architect-host.js:94:23)
at WorkspaceNodeModulesArchitectHost.getBuilderNameForTarget (C:\Users\Adam\source\repos\TechScore.Express\node_modules\@angular-devkit\architect\node\node-modules-architect-host.js:13:39)
at RunCommand.runSingleTarget (C:\Users\Adam\source\repos\TechScore.Express\node_modules\@angular\cli\models\architect-command.js:175:55)
at RunCommand.runArchitectTarget (C:\Users\Adam\source\repos\TechScore.Express\node_modules\@angular\cli\models\architect-command.js:218:35)
at RunCommand.run (C:\Users\Adam\source\repos\TechScore.Express\node_modules\@angular\cli\commands\run-impl.js:14:25)
at RunCommand.validateAndRun (C:\Users\Adam\source\repos\TechScore.Express\node_modules\@angular\cli\models\command.js:134:39)
at process._tickCallback (internal/process/next_tick.js:68:7)
at Function.Module.runMain (internal/modules/cjs/loader.js:834:11)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
于是我打开node-modules-architect-host.js:94:23 看到了这个:
const projectDefinition = this._workspace.projects.get(target.project);
if (!projectDefinition) {
throw new Error('Project does not exist.');
}
我不知道他们为什么会抛出这样的错误而不告诉你哪个项目不存在。所以我把文件改成这样:
throw new Error('Project does not exist. ' + target.project);
现在,当我构建时,我收到了这样的错误:
An unhandled exception occurred: Project does not exist. client-app
我终于知道谁是罪魁祸首了!对“client-app”的全局搜索显示它是从package.json 使用的,但我在angular.json 中的项目是“ClientApp”。将“ClientApp”的所有引用更改为“client-app”为我解决了这个问题。