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

Support Nitro (unjs) #20339

Closed
birkskyum opened this issue Aug 31, 2023 · 4 comments
Closed

Support Nitro (unjs) #20339

birkskyum opened this issue Aug 31, 2023 · 4 comments
Assignees
Labels
bug Something isn't working correctly node compat

Comments

@birkskyum
Copy link
Contributor

birkskyum commented Aug 31, 2023

Nitro - Website - GitHub

Nitro is used as a server of Nuxt, Analog, SolidStart etc.

Repro:

  • deno run -A npm:giget@latest nitro nitro-app
  • cd nitro-app
  • deno run -A npm:nitropack dev
Local:    http://localhost:3000/
  ➜ Network:  use --host to expose

[nitro 8:54:27 PM]Nitro built in 464 ms
error: Uncaught (in worker "$DENO_STD_NODE_WORKER_THREAD") TypeError: Cannot read properties of undefined (reading 'env')
    at file:///Users/admin/repos/deno-kitchensink/examples/nitro-app-2/.nitro/dev/index.mjs:1:58
error: Uncaught TypeError: Cannot create property 'message' on string 'Uncaught TypeError: Cannot read properties of undefined (reading 'env')'
    at _Worker.<anonymous> (file:///Users/admin/repos/deno-kitchensink/examples/nitro-app-2/node_modules/.deno/nitropack@2.6.2/node_modules/nitropack/dist/shared/nitro.f2f272d0.mjs:208:19)
    at Object.onceWrapper (ext:deno_node/_events.mjs:507:26)
    at _Worker.emit (ext:deno_node/_events.mjs:382:28)
    at Worker.<anonymous> (node:worker_threads:97:52)
    at innerInvokeEventListeners (ext:deno_web/02_event.js:750:7)
    at invokeEventListeners (ext:deno_web/02_event.js:797:5)
    at dispatch (ext:deno_web/02_event.js:654:9)
    at Worker.dispatchEvent (ext:deno_web/02_event.js:1039:12)
    at Worker.#handleError (ext:runtime/11_workers.js:133:10)
    at Worker.#pollControl (ext:runtime/11_workers.js:158:33)
    at eventLoopTick (ext:core/01_core.js:183:11)
@birkskyum birkskyum changed the title Support Nitro/nitropack Support Nitro (unjs) Sep 20, 2023
@kt3k kt3k added bug Something isn't working correctly node compat labels Sep 26, 2023
@bartlomieju
Copy link
Member

The problem here appears to be that process.env is not defined - the file being executed (./nitro/dev/index.mjs) is not considered to be a Node file (even though it should).

@bartlomieju
Copy link
Member

@littledivy suggests that this file is require()d and the context that it is evaluated in should have Node globals available. I will verify this.

@birkskyum
Copy link
Contributor Author

Another nitro ticket is the issue of uWebSockets.js

error: npm package 'uWebSockets.js' does not exist.

@birkskyum
Copy link
Contributor Author

birkskyum commented Aug 5, 2024

If i run without DENO_FUTURE=1 i get:

➜ deno run -A npm:nitropack dev              
error: npm package 'uWebSockets.js' does not exist.

But with DENO_FUTURE=1 deno task dev things are working (🎉 ):

➜ DENO_FUTURE=1 deno task dev                 
Task dev nitro dev

  ➜ Local:    http://localhost:3000/
  ➜ Network:  use --host to expose

✔ Nitro Server built in 434 ms 

It's just like:

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

No branches or pull requests

3 participants