Skip to content

[ng serve]: webpack-dev-middleware Error: ENOENT: no such file or directory #23844

Closed

Description

@ramoncarreras

Command

serve

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

14.1.3

Description

After upgrading to angular 14.2.0 and serving the APP locally, I get the following error:

[webpack-dev-middleware] Error: ENOENT: no such file or directory, readdir '<project-directory>/test-app/dist/test-app/'
    at createError (<project-directory>/test-app/node_modules/memfs/lib/volume.js:128:17)
    at Volume.readdirBase (<project-directory>/test-app/node_modules/memfs/lib/volume.js:1415:19)
    at Immediate.<anonymous> (<project-directory>/test-app/node_modules/memfs/lib/volume.js:695:33)
    at processImmediate (node:internal/timers:466:21) {
  code: 'ENOENT'
}

Minimal Reproduction

I created a minimal reproduction in the following repository:

https://github.com/ramoncarreras/angular-test-app

I have tried to minimize the issue as I could, sorry in advance (also see each commit).

In the README.md of the above repository there is a small description of the steps to follow.

The issue appears when I add the localize and the PWA official angular packages.

Exception or Error

[webpack-dev-middleware] Error: ENOENT: no such file or directory, readdir '<project-directory>/test-app/dist/test-app/'
    at createError (<project-directory>/test-app/node_modules/memfs/lib/volume.js:128:17)
    at Volume.readdirBase (<project-directory>/test-app/node_modules/memfs/lib/volume.js:1415:19)
    at Immediate.<anonymous> (<project-directory>/test-app/node_modules/memfs/lib/volume.js:695:33)
    at processImmediate (node:internal/timers:466:21) {
  code: 'ENOENT'
}

Your Environment

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 14.2.1
Node: 16.14.0
Package Manager: npm 8.5.3 
OS: darwin x64

Angular: 14.2.0
... animations, common, compiler, compiler-cli, core, forms
... localize, platform-browser, platform-browser-dynamic, router
... service-worker

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1402.1
@angular-devkit/build-angular   14.2.1
@angular-devkit/core            14.2.1
@angular-devkit/schematics      14.2.1
@angular/cli                    14.2.1
@schematics/angular             14.2.1
rxjs                            7.5.6
typescript                      4.7.4

Anything else relevant?

I can build the app locally without any problem. The error only shows when executing the ng serve command.

Also, I was able to reproduce the error in Ubuntu 20.04.

Activity

  1. self-assigned this
    on Sep 2, 2022
  2. jornare commented on Sep 2, 2022

    @jornare

    Same, Windows 10

  3. added 4 commits that reference this issue on Sep 2, 2022
    41a0b11
    75d332b
    42555d8
    cd0a6a1
  4. added a commit that references this issue on Sep 2, 2022
    ecc014d
  5. 13 remaining items

  6. julienvonoetinger-eaton commented on Sep 7, 2022

    @julienvonoetinger-eaton

    Same error shows for me after ng add @angular/pwa

    #edit If I set "serviceWorker": false in angular.json error is gone.

    The only issue with this is that it will completely disable the service work when you run ng serve AND ng build. I don't think there is a way to enable this flag only when you build.

  7. troncomputers commented on Sep 7, 2022

    @troncomputers

    @julien-von-oetinger so it is an issue with service-worker/pwa? I need it to be disabled on ng serve, because I am not able to code, but ultimately I want pwa to work.

  8. julienvonoetinger-eaton commented on Sep 7, 2022

    @julienvonoetinger-eaton

    @troncomputers Yes I think it related to pwa. You can disable it in order to be able to work as a workaround. But when you'll build your application, the worker will be disabled too. So I'm afraid we will have to wait for a fix from the Angular team for this issue. In the meantime I'm just setting the flag to false and then set if back to true before building in my CI/CD scripts.

  9. troncomputers commented on Sep 7, 2022

    @troncomputers

    @julien-von-oetinger or we could downgrade the angular to working version 🤔

  10. julienvonoetinger-eaton commented on Sep 7, 2022

    @julienvonoetinger-eaton

    @troncomputers sure that's probably the best option for now.

  11. fr20587 commented on Sep 7, 2022

    @fr20587

    The problem is that webpack cant find in which file and line is the code error, so I solved the problem seeking file by file the problem. This problem started after udpate all packeges with npm-check-updates

  12. troncomputers commented on Sep 8, 2022

    @troncomputers

    @fr20587 I did use npm-check-update when I start the project, but for me the error started to show after I install @angular/pwa

  13. julienvonoetinger-eaton commented on Sep 8, 2022

    @julienvonoetinger-eaton

    @fr20587 I'm not using npm-check-update but still got the issue after I updated to 14.2.0

  14. alan-agius4 commented on Sep 8, 2022

    @alan-agius4
    Collaborator

    The fix for this will be released later today in 14.2.2.

  15. troncomputers commented on Sep 8, 2022

    @troncomputers

    Update is available and I was able to enable "serviceWorker": true, ✌

  16. julienvonoetinger-eaton commented on Sep 8, 2022

    @julienvonoetinger-eaton

    Same for me ! The issue is gone ! Thanks @alan-agius4 👍

  17. Ruslancic commented on Sep 14, 2022

    @Ruslancic

    I had the same problem too, after updating to 14.2.2, everything disappeared!

    P.S Every simple error on my project, triggering this error!

  18. angular-automatic-lock-bot commented on Oct 15, 2022

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  19. locked and limited conversation to collaborators on Oct 15, 2022
  20. added a commit that references this issue on Feb 19, 2025
    f86b384
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions