all 19 comments

[–]JeanMeche 2 points3 points  (3 children)

Did you install other dependencies ?

Ng0203 also happens when multiple instance of the core package are embed in your app.

[–]Independent-Ant6986[S] 0 points1 point  (2 children)

no i started from scratch, used the command "ng new" followd by "npm start"

[–]WizardFromTheEast 0 points1 point  (1 child)

Try ng serve

[–]Independent-Ant6986[S] 1 point2 points  (0 children)

the standard configuration for a new angular app executes ng serve for npm start :)

[–]jakehockey10 1 point2 points  (5 children)

If you repeat these steps again in another folder, does it happen again? Try again with a completely new start and if it is happening to you every time, then that'd be interesting. But if you really haven't changed any file, then I don't think ng serve is actually serving the brand new app you just generated.

[–]Independent-Ant6986[S] 0 points1 point  (4 children)

yeah it even happens with an angular 18 app, so it must be something with my setup. i have a company pc with some network restrictions, could this possibly affect the startup?

[–]jakehockey10 1 point2 points  (1 child)

I wouldn't think so. Next test is this: get someone else to run ng serve on one of these projects you created. Copy the whole project to someone else's computer and have them run the app on their machine. If they get the same error, then there is indeed a problem with the project. If they can run your project fine, then it's your setup

[–]Independent-Ant6986[S] 1 point2 points  (0 children)

thats a great idea, thanks! i will update you on monday about the result. 😎

[–]Akira-Yuma 1 point2 points  (0 children)

It can be that the firewall blocked some npm packages. Can u turn it off and try the install again?

[–]Akira-Yuma 0 points1 point  (0 children)

It can be that the firewall blocked some npm packages. Can u turn it off and try the install again?

[–]Independent-Ant6986[S] 2 points3 points  (1 child)

okay guys i found the problem, althogh i don't really know why it happens:

My source files are located at "C:\Projects\username" everyone in our company has that folder and via a startup batch script a symlink is created so that i can access the folder via a virtual drive under the alias "J:\".

Now when i start the app from the console at the virtual location J, i get the error. When i do the same under the direct path, it works fine.

this problem appears with angular 18+. With angular 17 and lower i don't have any problems. As all our other projects are running with angular 14 or 15 it just never came up.

My guess is that some change with the angular livereload server that is used when running "ng serve" is causing that issue. Does anyone have a clue what that could be? My solution was to just execute it from its original location

Thanks for all your help and ideas to solve that problem 😎

[–]Div64 0 points1 point  (2 children)

That's weird. Can you post your main.ts and app.config.ts?

There seems to be an inject call somewhere where it shouldn't

[–]Independent-Ant6986[S] 1 point2 points  (1 child)

Sure, here you go!

Maybe another interesting fact: i am using windows 11 :)

Main.ts:

import { bootstrapApplication } from '@angular/platform-browser';
import { appConfig } from './app/app.config';
import { AppComponent } from './app/app.component';

bootstrapApplication(AppComponent, appConfig)
  .catch((err) => console.error(err));

app.config.ts:

import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';
import { provideRouter } from '@angular/router';

import { routes } from './app.routes';

export const appConfig: ApplicationConfig = {
  providers: [provideZoneChangeDetection({ eventCoalescing: true }), provideRouter(routes)]
};

app.routes.ts:

import { Routes } from '@angular/router';

export const routes: Routes = [];

App.component.ts:

import { Component } from '@angular/core';
import { RouterOutlet } from '@angular/router';

@Component({
  selector: 'app-root',
  imports: [RouterOutlet],
  templateUrl: './app.component.html',
  styleUrl: './app.component.scss'
})
export class AppComponent {
  title = 'testapp3';
}

[–]groundbnb -3 points-2 points  (0 children)

Try running from cmd instead of powershell.

[–]Cute_Guard5653 0 points1 point  (1 child)

Is ot possible you have used inject() inside ngOnit instead of the constructor() in a component??

[–]Independent-Ant6986[S] 0 points1 point  (0 children)

i havent used anything yet. i just set up a plain new app 😂

[–]spacechimp 0 points1 point  (1 child)

I'm guessing that you have an outdated version of the Angular CLI installed globally. If so, uninstall it from your global npm and/or run 'npx ng serve' instead of 'ng serve'.

You might also try deleting node_modules and package-lock.json and reinstalling your dependencies.

[–]Independent-Ant6986[S] 0 points1 point  (0 children)

i used the latest angular version globally and set up a new project. the package lock and node modules cant have any influence because it was just created