angular-cli: [ng serve]: webpack-dev-middleware Error: ENOENT: no such file or directory
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.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 15
- Comments: 27
Commits related to this issue
- fix(@angular-devkit/build-angular): handle service-worker servering with localize in dev-server Previously, we tried to read the files from the wrong location as during localize we alter the output d... — committed to alan-agius4/angular-cli by alan-agius4 2 years ago
- fix(@angular-devkit/build-angular): handle service-worker serving with localize in dev-server Previously, we tried to read the files from the wrong location as during localize we alter the output dir... — committed to alan-agius4/angular-cli by alan-agius4 2 years ago
- fix(@angular-devkit/build-angular): handle service-worker serving with localize in dev-server Previously, we tried to read the files from the wrong location as during localize we alter the output dir... — committed to alan-agius4/angular-cli by alan-agius4 2 years ago
- fix(@angular-devkit/build-angular): handle service-worker serving with localize in dev-server Previously, we tried to read the files from the wrong location as during localize we alter the output dir... — committed to alan-agius4/angular-cli by alan-agius4 2 years ago
- fix(@angular-devkit/build-angular): handle service-worker serving with localize in dev-server Previously, we tried to read the files from the wrong location as during localize we alter the output dir... — committed to angular/angular-cli by alan-agius4 2 years ago
The fix for this will be released later today in 14.2.2.
Same error shows for me after
ng add @angular/pwa
#edit If I set
"serviceWorker": false
inangular.json
error is gone.Following up on the cause for this error being a compilation error (as mentioned by @alan-agius4 above), one workaround for this issue is:
It should now work.
Same for me ! The issue is gone ! Thanks @alan-agius4 👍
@troncomputers sure that’s probably the best option for now.