Angular 6找不到.angular-cli.json,如何修改outDir?
Hey there! Let's sort out your issues step by step—this is a super common problem when following older Angular tutorials with newer CLI versions.
Why you can't find .angular-cli.json
The tutorial you're using is for Angular CLI 1.x, which relied on .angular-cli.json for configuration. Starting with Angular 6+, the CLI switched to using angular.json as the main config file. That's why you can't locate the old file!
Correctly setting the build output directory
You mentioned editing tsconfig.json's outDir—but that's for intermediate TypeScript compilation files, not the final bundled production build. Here's how to set the actual output path:
- Open your project's
angular.jsonfile (it lives in the root directory). - Navigate to
projects -> [your-project-name] -> architect -> build -> options. - Look for the
outputPathproperty (defaults to"dist/[your-project-name]"). - Change this to the directory your backend expects (e.g.,
"../backend/public"if your backend serves static files from apublicfolder). - Run
ng build(add--prodfor production-ready bundles) — your compiled files will now go to the path you set.
Integrating Angular with your existing backend (run on localhost:3000)
You have two main options depending on whether you're in development or production:
Production setup
- Build your Angular app with the correct
outputPathpointing to your backend's static file directory (following the step above). - Start your backend server—when you visit
localhost:3000, your backend will serve the Angular app files directly.
Development setup (with hot-reload)
If you want to keep using Angular's live-reload during development while proxying API calls to your backend:
- Create a
proxy.conf.jsonfile in your Angular project root with this content:
(Adjust{ "/api/*": { "target": "http://localhost:3000", "secure": false, "changeOrigin": true } }/api/*to match your backend's API route prefix.) - Open
angular.json, go toprojects -> [your-project-name] -> architect -> serve -> options, and add:"proxyConfig": "proxy.conf.json" - Start your backend server on
localhost:3000. - Run
ng serve(it will default tolocalhost:4200). Any API requests from your Angular app to/api/...will automatically forward to your backend atlocalhost:3000, while you get all the live-reload benefits for your frontend code.- If you want to access everything on
localhost:3000during development, you can configure your backend to serve the Angular dev server's files, but proxying is usually simpler and faster.
- If you want to access everything on
内容的提问来源于stack exchange,提问作者Igor Ivanov

