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

Use entrypoint from resources #820

Closed
sushant-at-nitor opened this issue Oct 12, 2020 · 8 comments
Closed

Use entrypoint from resources #820

sushant-at-nitor opened this issue Oct 12, 2020 · 8 comments

Comments

@sushant-at-nitor
Copy link

sushant-at-nitor commented Oct 12, 2020

I use @vercel/ncc to compile the module in single file(index.js), I am also adding this to resources using --resources option

Can I use the index.js from resources as the entrypoint?

@calebboyd
Copy link
Member

-i index.js or nexe index.js is what you're after

@sushant-at-nitor
Copy link
Author

@calebboyd - thank you for quick response.

I tried this, but I still need to keep bundle along side the my-app.exe

nexe -t x64-10.9.0 --resource "./bundle/**/*" -i bundle/index.js -o my-app.exe

I wanted to check if there is any option so I don't have to provide index.js separately

@calebboyd
Copy link
Member

calebboyd commented Oct 12, 2020

That shouldn't be necessary, do you have a minimal reproduction?
or are you just wondering how to make the command less verbose..

@sushant-at-nitor
Copy link
Author

Sure, I can provide you that. But if I copy the exe to some other location and when I try to execute I get following exception:

Error: Cannot find module '<some-other-path>\bundle\index.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
    at Function.Module._load (internal/modules/cjs/loader.js:507:25)
    at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
    at Object.<anonymous> (e:\Projects\Qentinel\ws\qt-ps.exe:352:30)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at _third_party_main.js:37:36
    at NativeModule.compile (internal/bootstrap/loaders.js:271:7)
    at Function.NativeModule.require (internal/bootstrap/loaders.js:164:18)
    at internal/bootstrap/node.js:232:22
    at process._tickCallback (internal/process/next_tick.js:61:11)

@sushant-at-nitor
Copy link
Author

@calebboyd - here is my directory structure. I would like to execute the bundle/index.js from the executable, if I execute it from app directory it works fine but if I copy executable to some other directory then it gives above error

app

  • src/
  • dist/
  • bundle/
    • index.js
  • package.json

@calebboyd
Copy link
Member

I can't reproduce this with the information here
Running nexe against a similar tree and moving it doesn't seem to cause issues

code/test > nexe app/bundle/index.js -o out -t 14.15.3
ℹ nexe 4.0.0-beta.15
✔ Already downloaded...
✔ Compiling result
✔ Entry: 'app/bundle/index.js' written to: out
✔ Finished in 0.113s
code/test > ./out
hello world
code/test > mv out ~/Desktop/out
code/test > cd ~/Desktop
~/Desktop > ./out
hello world

@github-actions
Copy link

Closed awaiting response from OP, please open a new issue with the requested information and/or examples

@sn0wst0rm
Copy link

sn0wst0rm commented May 16, 2024

I have the same problem here. My main entry point for the app is index.js. I build everything (node 20.13.0) with next server.js --build, and it prodouces a bundled executable named 'server'. if I run the executable from the same folder it was created in, everything is fine, but if I try to cp it anywhere else in the disk and execute it, it crashes with:

node:internal/fs/promises:636
  return new FileHandle(await PromisePrototypeThen(
                        ^

Error: ENOENT: no such file or directory, open '/path/to/server.js'
    at async open (node:internal/fs/promises:636:25)
    at async readFile (node:internal/fs/promises:1246:14)
    at async getSource (node:internal/modules/esm/load:46:14)
    at async defaultLoad (node:internal/modules/esm/load:137:34)
    at async ModuleLoader.load (node:internal/modules/esm/loader:396:7)
    at async ModuleLoader.moduleProvider (node:internal/modules/esm/loader:278:45)
    at async link (node:internal/modules/esm/module_job:78:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/path/to/server.js'
}

@calebboyd try to bundle a file and then copy the executable somewhere completely different, like downloads and see if this also happens to you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants