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

Project built with node standalone adapter tied to node_modules #7247

Closed
1 task
drocha87 opened this issue May 30, 2023 · 4 comments
Closed
1 task

Project built with node standalone adapter tied to node_modules #7247

drocha87 opened this issue May 30, 2023 · 4 comments

Comments

@drocha87
Copy link

drocha87 commented May 30, 2023

What version of astro are you using?

2.4.5

Are you using an SSR adapter? If so, which one?

Node

What package manager are you using?

npm

What operating system are you using?

Linux

What browser are you using?

Edge

Describe the Bug

The process of building a node standalone project currently has a dependency on the specific machine used for building it. This is my astro.config.mjs

 // https://astro.build/config
export default defineConfig({
  integrations: [tailwind()],
  output: "server",
  server: {
    host: "127.0.0.1",
    port: 3000,
  },
  adapter: node({
    mode: "standalone",
  }),
  vite: {
    esbuild: { minifyIdentifiers: false },
    ssr: { noExternal: ["jsonwebtoken"] },
  },
});

This limitation is not allowing me to run the built project on different machines. For example I have this error when trying to run it on another machine:

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'undici' imported from /home/user/dist/server/entry.mjs

Update: If I move the node_modules along with the dist it seems to fix the problem.

To reproduce the problem just build the project and move the dist folder to outside of the project root and then try to run it.

Link to Minimal Reproducible Example

https://github.com/drocha87/lonely-light

Participation

  • I am willing to submit a pull request for this issue.
@drocha87 drocha87 changed the title Project built with node standalone adapter tied to specific machine Project built with node standalone adapter tied to node_modules May 31, 2023
@bluwy
Copy link
Member

bluwy commented Jun 5, 2023

This is intentional with the node integration. The typical flow when deploying a node app on a prod server is to copy the dist/ and package.json, then run npm install -P, and you can start the prod server. If you'd like to bundle everything, you can set vite.ssr.noExternal: true.

@bluwy bluwy closed this as not planned Won't fix, can't repro, duplicate, stale Jun 5, 2023
@Whyjsee
Copy link

Whyjsee commented Sep 19, 2023

This is intentional with the node integration. The typical flow when deploying a node app on a prod server is to copy the dist/ and package.json, then run npm install -P, and you can start the prod server. If you'd like to bundle everything, you can set vite.ssr.noExternal: true.

thx bro ~! you saved me today !

@alator21
Copy link

This is intentional with the node integration. The typical flow when deploying a node app on a prod server is to copy the dist/ and package.json, then run npm install -P, and you can start the prod server. If you'd like to bundle everything, you can set vite.ssr.noExternal: true.

@bluwy which are the dependencies exactly that are needed so I can start my app? I have copied dist the folder and I'm wondering why would I need all the dependencies again after already building the project during the build command.

@shelchin2023
Copy link

This is intentional with the node integration. The typical flow when deploying a node app on a prod server is to copy the dist/ and package.json, then run npm install -P, and you can start the prod server. If you'd like to bundle everything, you can set vite.ssr.noExternal: true.

thx bro ~! you saved me today !

When I introduce react, the build product has a dependency on node_modules/react-dom. have you guys come across this?
image

Reproducible: https://github.com/shelchin2023/test-astro-ssr

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

5 participants