确保您的项目名称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”解决了我的问题。