Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unknown option: '--base-href' Angular 13 ng serve

Tags:

angular

im creating an angular 13app using CLI i want to set a path to my app when i run it i got the following error :

Unknown option: '--base-href'
Unknown option: '/my-path/'

this is the command i run :

ng serve --base-href /my-path/

and

ng serve --base-href=/my-path/

and this are my dep :

  "dependencies": {
    "@angular/animations": "~13.2.0",
    "@angular/common": "~13.2.0",
    "@angular/compiler": "~13.2.0",
    "@angular/core": "~13.2.0",
    "@angular/forms": "~13.2.0",
    "@angular/platform-browser": "~13.2.0",
    "@angular/platform-browser-dynamic": "~13.2.0",
    "@angular/router": "~13.2.0",
    "@ng-bootstrap/ng-bootstrap": "^4.1.1",
    "@reactivex/rxjs": "^6.6.7",
    "angular-oauth2-oidc": "^13.0.1",
    "bootstrap-icons": "^1.8.1",
    "font-awesome": "^4.7.0",
    "rxjs": "~7.5.0",
    "tslib": "^2.3.0",
    "zone.js": "~0.11.4"
  },

any one have an idea about this isuue please and how i can set a path to my app in localhost ?

Regards

like image 734
James Avatar asked Jan 21 '26 16:01

James


2 Answers

This option has been deprecated. You should set it in angular.json, here :

    "acme-project": {
      [...]
      "architect": {
        "build": {
          "options": {
            "baseHref": "/my-path/",
like image 65
Arnaud Denoyelle Avatar answered Jan 23 '26 10:01

Arnaud Denoyelle


Adding to Arnauds answer.

If you don't want to change the baseHref for your development and perhaps not all builds, you should add baseHref to 'configurations' on selected config, and not to 'options.

f ex: in my project AngularExamplesAndSnippets i add the baseHref to my "github-pages" configuration

if you build for production you add it below "production"

"build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            ... 
          },
          "configurations": {
            "github-pages": {
              "baseHref": "/AngularExamplesAndSnippets/",
              ...
            }
like image 26
JimiSweden Avatar answered Jan 23 '26 09:01

JimiSweden



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!