Skip to content

Errors are reported differently depending on when you execute npm start #17487

Closed
@DeborahK

Description

@DeborahK

🐞 Bug report

Command (mark with an x)

  • new
  • build
  • [x ] serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • xi18n
  • run
  • config
  • help
  • version
  • doc

Is this a regression?

Yes. In Angular v8 and before, the browser would consistently show errors, regardless of when you executed `npm start`

Description

What you see in the browser when you have an error depends on when you execute `npm start`. You may get this:

image
No error shown. Appears to display the last successfully compiled files.

You may get this:

image
Get error. This is very unhelpful, especially for Angular beginners. This appears if you run npm start after making an error. It appears that it cannot serve any files in this case.

Or you may get lucky and get this:

image
This is much more helpful, but not consistently shown.

🔬 Minimal Reproduction

This is one example, but it happens with many different errors, such as forgetting to add a component to an Angular module:

  1. ng new APM
  2. cd APM
  3. code .
  4. Run npm start
  5. Add the following line to the template: <input type='text' [(ngModel)]='listFilter' />
    (This is an error because we don't have listFilter defined and we have not imported FormsModule.)
  6. View the browser. No error.
  7. Using the F12 tools, you see the ngModel error.
  8. Stop the compiler.
  9. Restart the compiler and you see the black background and an error in the browser.
    I assume this is the behavior that we should see in every case.
  10. Remove the added input line. The code does not recompile and the browser still shows the error. So it appears as if it was not fixed.
  11. Stop the compiler.
  12. Add the above input element again (step Concatenate all source files  #5)
  13. Start the compiler.
  14. This time you'll see the cannot get error.

So depending on when the npm start is executed, the developer will see different results, some of which, like the cannot get error, provide no information in the browser as to what is wrong.

🔥 Exception or Error





🌍 Your Environment




@angular-devkit/build-angular     0.901.1
@angular-devkit/build-optimizer   0.901.1
@angular-devkit/build-webpack     0.901.1
@angular-devkit/core              9.1.1
@angular-devkit/schematics        9.1.1
@ngtools/webpack                  9.1.1
@schematics/angular               9.1.1
@schematics/update                0.901.1
rxjs                              6.5.5
typescript                        3.8.3
webpack                           4.42.0

Anything else relevant?

Similar issues: #15887

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions