Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: ENOENT: no such file or directory #29227

Closed
draylegend opened this issue Dec 24, 2024 · 1 comment
Closed

Error: ENOENT: no such file or directory #29227

draylegend opened this issue Dec 24, 2024 · 1 comment

Comments

@draylegend
Copy link

Which @angular/* package(s) are the source of the bug?

compiler, compiler-cli

Is this a regression?

Yes

Description

I'm trying to use elysia instead of express and the application is loading properly, but I encountered an error while building the app.

It seems the build is expecting a browser directory in the .angular/prerender-root path, which is missing.

Please provide a link to a minimal reproduction of the bug

https://github.com/draylegend/elysia-static-bugs

Please provide the exception or error you saw

/home/dl/elysia-static-bugs/node_modules/.bin/nx run app:build

> nx run app:build:production


Error: ENOENT: no such file or directory, scandir '/home/dl/elysia-static-bugs/.angular/prerender-root/browser'
    at async readdir (node:internal/fs/promises:950:18)
    at async xd (file:///home/dl/elysia-static-bugs/.angular/prerender-root/24ad1a33-bc90-456d-a021-f501fd639e6a/server.mjs:316:16758)
    at async Id (file:///home/dl/elysia-static-bugs/.angular/prerender-root/24ad1a33-bc90-456d-a021-f501fd639e6a/server.mjs:316:17397)
    at async _i.drain (file:///home/dl/elysia-static-bugs/.angular/prerender-root/24ad1a33-bc90-456d-a021-f501fd639e6a/server.mjs:8:43953) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'scandir',
  path: '/home/dl/elysia-static-bugs/.angular/prerender-root/browser'
}
Error: ENOENT: no such file or directory, scandir '/home/dl/elysia-static-bugs/.angular/prerender-root/browser'
    at async readdir (node:internal/fs/promises:950:18)
    at async xd (file:///home/dl/elysia-static-bugs/.angular/prerender-root/59adf74f-e832-4d1c-8571-52631a8a516b/server.mjs:316:16758)
    at async Id (file:///home/dl/elysia-static-bugs/.angular/prerender-root/59adf74f-e832-4d1c-8571-52631a8a516b/server.mjs:316:17397)
    at async _i.drain (file:///home/dl/elysia-static-bugs/.angular/prerender-root/59adf74f-e832-4d1c-8571-52631a8a516b/server.mjs:8:43953) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'scandir',
  path: '/home/dl/elysia-static-bugs/.angular/prerender-root/browser'
}
Browser bundles     
Initial chunk files  | Names            |  Raw size | Estimated transfer size
main-GFSKVUMT.js     | main             | 217.62 kB |                60.04 kB
styles-YYJXJO7S.css  | styles           |   4.66 kB |                 1.17 kB

                     | Initial total    | 222.28 kB |                61.21 kB


Server bundles      
Initial chunk files  | Names            |  Raw size
main.server.mjs      | main.server      | 725.71 kB |                        
server.mjs           | server           | 255.82 kB |                        
polyfills.server.mjs | polyfills.server | 237.05 kB |                        
chunk-JAEHAS6C.mjs   | -                |   1.52 kB |                        
chunk-T55IDOPT.mjs   | -                | 976 bytes |                        

Lazy chunk files     | Names            |  Raw size
chunk-PORXTWD6.mjs   | xhr2             |  12.14 kB |                        
chunk-N3SI5I4Q.mjs   | xhr2             |  12.07 kB |                        

Prerendered 1 static route.
Application bundle generation complete. [9.428 seconds]

Output location: /home/dl/elysia-static-bugs/dist/apps/app


——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

 NX   Successfully ran target build for project app (10s)


Process finished with exit code 0

Please provide the environment you discovered this bug in (run ng version)

$ nx report

 NX   Report

Node           : 22.10.0
OS             : linux-x64
Native Target  : x86_64-linux
bun            : 1.1.42

nx (global)            : 20.2.1
nx                     : 20.3.0
@nx/js                 : 20.3.0
@nx/eslint             : 20.3.0
@nx/workspace          : 20.3.0
@nx/angular            : 20.3.0
@nx/devkit             : 20.3.0
@nx/eslint-plugin      : 20.3.0
@nx/module-federation  : 20.3.0
@nx/playwright         : 20.3.0
@nx/vite               : 20.3.0
@nx/web                : 20.3.0
@nx/webpack            : 20.3.0
typescript             : 5.6.3
---------------------------------------
Registered Plugins:
@nx/playwright/plugin
@nx/eslint/plugin
---------------------------------------
Community plugins:
@analogjs/vite-plugin-angular : 1.10.3
@analogjs/vitest-angular      : 1.10.3
angular-eslint                : 19.0.3-alpha.0

WSL version: 2.2.4.0
Kernel version: 5.15.153.1-2
WSLg version: 1.0.61
MSRDC version: 1.2.5326
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.26091.1-240325-1447.ge-release
Windows version: 10.0.26100.2605

Anything else?

No response

@JeanMeche JeanMeche transferred this issue from angular/angular Dec 24, 2024
@alan-agius4
Copy link
Collaborator

The issue arises during the build process when static assets are missing, causing @elysiajs/static to fail if the directory does not exist.

To resolve this, you can either register the plugin when isMainModule(import.meta.url) returns true or implement a safety check to ensure the directory exists.
Here's a refined version of your note for clarity and precision:

Side note: I noticed that the AngularAppEngine is initialized for every request, which negatively impacts performance.

Consider instantiating it once and reusing the instance:

-  .get('/*', c => new AngularAppEngine().handle(c.request));
+  const appEngine = new AngularAppEngine();
+  .get('/*', c => appEngine.handle(c.request));

@alan-agius4 alan-agius4 closed this as not planned Won't fix, can't repro, duplicate, stale Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants