Angular 6构建Universal应用时遇'Project testapp未在工作区找到'错误求助
Hey there, let's work through that frustrating error you're seeing when trying to build your Angular 6 Universal app. Here are some practical steps to troubleshoot and fix it:
1. Confirm you're in the correct working directory
First, make sure you’re running your build command from the root folder of your Angular project—this is the folder that contains the angular.json file. To check your current path:
- On Mac/Linux: Run
pwdin your terminal - On Windows: Run
cd(without arguments) in Command Prompt or PowerShell
If you’re not in the testapp root folder, navigate there with cd testapp before running your build command.
2. Check the project name in your angular.json
Open up your angular.json file and look for the "projects" section. The key for your project here needs to exactly match the name you’re using in your build command (in this case, testapp). It’s easy to accidentally use a different name when creating the project—like test-app with a hyphen, or a lowercase variation. If the names don’t match, update your build command to use the exact project name from the config file.
3. Simplify your build command (for default projects)
If testapp is the only project in your workspace, you can skip the --project flag entirely. Just run:
ng build
Angular will automatically use the default project defined in your angular.json.
4. Repair a corrupted workspace configuration
If your angular.json file got damaged during the Universal setup process, try these steps:
- Delete the
node_modulesfolder andpackage-lock.jsonfile from your project root - Run
npm installto reinstall all dependencies - If that doesn’t fix it, run
ng update(ensure you’re using an Angular CLI version compatible with Angular 6) to repair the workspace setup
One of these steps should get your build working smoothly again!
内容的提问来源于stack exchange,提问作者Pranab V V

