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

[🐞] Vanilla Node Server Adapter - Cannot find package 'undici' #6594

Open
RumNCodeDev opened this issue Jun 23, 2024 · 6 comments
Open

[🐞] Vanilla Node Server Adapter - Cannot find package 'undici' #6594

RumNCodeDev opened this issue Jun 23, 2024 · 6 comments
Labels
COMMUNITY: PR is welcomed We think it's a good feature to have but would love for the community to help with the PR for it STATUS-2: team is working on this Scheduled for work by the core team STATUS-2: waiting for community PR TYPE: bug Something isn't working

Comments

@RumNCodeDev
Copy link
Contributor

Which component is affected?

Qwik Rollup / Vite plugin

Describe the bug

I am attempting to build and deploy a QwikCity Web App to Azure using the Node.js Server (Vanilla Node server) adapter. However after running the build command, and copy/paste the dist and server folders into a new directory and attempting to run node server/entry.node-server I get the following error

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'undici' imported from /.../test/server/entry.node-server.js

Reproduction

https://stackblitz.com/edit/vitejs-vite-q5swzr?file=index.html

Steps to reproduce

  1. Create a minimal qwik application via npm create qwik@latest and select Empty App.
  2. Use npm qwik add to add the Adapter: Node.js Server (Vanilla Node server)
  3. Build the application using build command from the package.json
  4. Copy/Paste the dist and server files into a new directory outside of the current project structure (like you would for a production deploy)
  5. Run node server/entry.node-server in the new directory

System Info

System:
    OS: macOS 14.5
    CPU: (12) arm64 Apple M3 Pro
    Memory: 440.39 MB / 36.00 GB
    Shell: 5.9 - /bin/zsh
  npmPackages:
    @builder.io/qwik: ^1.5.7 => 1.5.7
    @builder.io/qwik-city: ^1.5.7 => 1.5.7
    @types/eslint: ^8.56.10 => 8.56.10
    @types/node: ^20.12.7 => 20.14.8
    @typescript-eslint/eslint-plugin: ^7.7.1 => 7.13.1
    @typescript-eslint/parser: ^7.7.1 => 7.13.1
    eslint: ^8.57.0 => 8.57.0
    eslint-plugin-qwik: ^1.5.7 => 1.5.7
    prettier: ^3.2.5 => 3.3.2
    typescript: 5.4.5 => 5.4.5
    undici: * => 6.19.2
    vite: ^5.2.10 => 5.3.1
    vite-tsconfig-paths: ^4.2.1 => 4.3.2

Additional Information

No response

@RumNCodeDev RumNCodeDev added STATUS-1: needs triage New issue which needs to be triaged TYPE: bug Something isn't working labels Jun 23, 2024
@gioboa
Copy link
Member

gioboa commented Jun 24, 2024

Hi @RumNCodeDev
in that file there is an import from undici
image
you can add this dependency in the package.json and install it, then you can start the server correctly.
image

we are importing crypto as well but we don't need to install it because node:internal manage it for us.

@RumNCodeDev
Copy link
Contributor Author

@gioboa how would I accomplish that as part of the pipeline as thats a generated file?

@gioboa
Copy link
Member

gioboa commented Jun 25, 2024

@gioboa how would I accomplish that as part of the pipeline as thats a generated file?

you can add a pnpm i undici step in your pipeline.

The original issue is solved, so I'm closing it for now.
Feel free to re-open it if it's still an issue for you. Thanks.

@gioboa gioboa closed this as completed Jun 25, 2024
@RumNCodeDev
Copy link
Contributor Author

RumNCodeDev commented Jun 25, 2024

@gioboa , so if i do that, then i get another error for zod missing, and if i add that, then im missing @auth/core, and so on... so I feel like the adapter just isn't working properly if i have to keep just adding all of my deps again? Shouldnt this all be handled by the build step?

@gioboa
Copy link
Member

gioboa commented Jun 25, 2024

Here you can find the Docker solution for a Qwik Node Server.

In a specific step is adding all the dependencies

# Download dependencies as a separate step to take advantage of Docker's caching.
# Leverage a cache mount to /root/.yarn to speed up subsequent builds.
# Leverage bind mounts to package.json and yarn.lock to avoid having to copy them
# into this layer.
RUN --mount=type=bind,source=package.json,target=package.json \
   --mount=type=bind,source=yarn.lock,target=yarn.lock \
   --mount=type=cache,target=/root/.yarn \
   yarn install --frozen-lockfile

I think we can improve this process, but it's definitively a feature request.

@shairez
Copy link
Contributor

shairez commented Jul 10, 2024

Re-opening because I think there's a DX problem to be solved here.

We either need to update the docs, or update the adapter to make sure devs are successful in installing the node adapter to be used in a regular server.

@shairez shairez reopened this Jul 10, 2024
@shairez shairez added COMMUNITY: PR is welcomed We think it's a good feature to have but would love for the community to help with the PR for it STATUS-2: waiting for community PR STATUS-2: team is working on this Scheduled for work by the core team and removed STATUS-1: needs triage New issue which needs to be triaged labels Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
COMMUNITY: PR is welcomed We think it's a good feature to have but would love for the community to help with the PR for it STATUS-2: team is working on this Scheduled for work by the core team STATUS-2: waiting for community PR TYPE: bug Something isn't working
Projects
Status: Backlog
Development

No branches or pull requests

3 participants