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

EINVAL / EPERM error when running build script on Windows due to D:\System Volume Information #6619

Open
ahmad-su opened this issue Apr 5, 2025 · 3 comments
Labels
bug Something isn't working

Comments

@ahmad-su
Copy link

ahmad-su commented Apr 5, 2025

Description

When trying to build the appworker thread using the build script (build-all or build-threads), I get either:

  • EINVAL: invalid argument, stat 'D:\System Volume Information', or
  • EPERM: operation not permitted, stat 'D:\System Volume Information' (when not running as administrator)

This occurs on Windows when building the Neo.mjs project.


Steps to Reproduce

  1. Run npx neo-app@latest or initiate a build using the generated script (npm run build-all or npm run build-threads).

Cause

The script (likely through ContextModule.resolveDependencies) tries to access restricted system folders like D:\System Volume Information, which is not permitted.


Environment

  • OS: Windows 11
  • Node.js: v23.10
  • Neo.mjs: latest
  • Terminal: PowerShell

Additional Info

It appears that Webpack is attempting to resolve .mjs files across the entire project directory, including protected system folders. This causes permission errors on Windows.


Log

neoapp buildThreads starting dist/production
assets by status 69.9 KiB [cached] 3 assets
orphan modules 202 KiB [orphan] 27 modules
runtime modules 3.37 KiB 8 modules
built modules 275 KiB [built]
  modules by path ./node_modules/neo.mjs/src/core/*.mjs 21.3 KiB
    ./node_modules/neo.mjs/src/core/Base.mjs 19.9 KiB [built] [code generated]
    ./node_modules/neo.mjs/src/core/IdGenerator.mjs 1.39 KiB [built] [code generated]
  modules by path ./node_modules/neo.mjs/src/util/*.mjs 10.1 KiB
    ./node_modules/neo.mjs/src/util/Function.mjs 5.31 KiB [built] [code generated]
    ./node_modules/neo.mjs/src/util/Array.mjs 4.76 KiB [built] [code generated]
  ./node_modules/neo.mjs/src/worker/App.mjs + 24 modules 212 KiB [built] [code generated]
  ../../../ lazy ^\.\/.*\.mjs$ include: (?:\/%7C\\)app.mjs$ exclude: (?:\/%7C\\)no...(truncated) 160 bytes [built] [code generated]
  ./node_modules/neo.mjs/src/remotes/Api.mjs 1.81 KiB [built] [code generated]
  ./node_modules/neo.mjs/src/vdom/Helper.mjs + 3 modules 30.1 KiB [built] [code generated]

ERROR in ../../../ lazy ^\.\/.*\.mjs$ include: (?:\/%7C\\)app.mjs$ exclude: (?:\/%7C\\)node_modules strict namespace object
EINVAL: invalid argument, stat 'D:\System Volume Information'
caused by plugins in ContextModule.resolveDependencies
Error: EINVAL: invalid argument, stat 'D:\System Volume Information'
 @ ./node_modules/neo.mjs/src/worker/App.mjs 301:19-306:13

What I’ve Tried

  • Reinstall dependencies & rebuild as administrator npm i && npm run build-threads : leads to EINVAL err
  • Filter out the system folder in neo.mjs/src/worker/App.mjs, but looks like it's not the case:
if (!path.includes('D:\\System')) {
    return import(
        /* webpackInclude: /(?:\/|\\)app.mjs$/ */
        /* webpackExclude: /(?:\/|\\)node_modules/ */
        /* webpackMode: "lazy" */
        `../../${path}.mjs`
    )
} 

Let me know if you need help reproducing it. Thanks

@ahmad-su ahmad-su added the bug Something isn't working label Apr 5, 2025
@ahmad-su
Copy link
Author

ahmad-su commented Apr 5, 2025

Update: Running the build command on git bash didnt solve the issue

@tobiu
Copy link
Collaborator

tobiu commented Apr 5, 2025

@ahmad-su Without having Windows installed, I can sadly not help too much on this one (flying blind).

I am sure though, that the problem is the following regex comment: /* webpackInclude: /(?:\/|\\)app.mjs$/ */.
For / based file systems it does work fine, for \ it looks like it does not.

Let me explain what it is supposed to do:

For a webpack based build, the app worker => worker/App.mjs file is supposed to find all app.mjs files.

Inside the framework repo, it needs to go 2 folder levels up (repo root), and it can then find the target files inside the apps, examples & docs folder.

Inside a workspace, it needs to go 4 folder levels up, since neo is inside node_modules/neo.mjs/.

If it would try to go further up, there might be security related restrictions (permission denied).

The main idea is, that by fetching all app.mjs files, we do get split chunks & tree-shaking across multiple apps out of the box. E.g. if you would lazy-load a 2nd neo app into your website, there should be little overhead.

@ahmad-su
Copy link
Author

ahmad-su commented Apr 5, 2025

Thanks for the insight @tobiu , the solution is just by nesting the project folder 1 level deeper. so ../.. will not accidentally go to D:
But I'm still curious to modify the App.mjs to make it work wherever I place the project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants