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

dist/server does not get created upon npm run build #13296

Open
1 task
eduardonwa opened this issue Feb 22, 2025 · 4 comments
Open
1 task

dist/server does not get created upon npm run build #13296

eduardonwa opened this issue Feb 22, 2025 · 4 comments
Labels
needs triage Issue needs to be triaged

Comments

@eduardonwa
Copy link

eduardonwa commented Feb 22, 2025

Astro Info

Astro                    v5.3.0
Node                     v18.20.7
System                   Linux (x64)
Package Manager          npm
Output                   server
Adapter                  @astrojs/vercel
Integrations             @sanity/astro
                         @astrojs/react

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

Everytime i make a commit to Github and Vercel tries to deploy the Astro project, Vercel fails because the adapter misses to create the "server" folder inside the dist

Logs say this:

    at new NodeError (node:internal/errors:405:5)
    at finalizeResolution (node:internal/modules/esm/resolve:332:11)
    at moduleResolve (node:internal/modules/esm/resolve:1029:10)
    at moduleResolveWithNodePath (node:internal/modules/esm/resolve:876:12)
    at defaultResolve (node:internal/modules/esm/resolve:1255:79)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:404:12)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:373:25)
    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:250:38)
    at ModuleLoader.import (node:internal/modules/esm/loader:336:34)
    at importModuleDynamically (node:internal/modules/cjs/loader:1256:33) {
  url: 'file:///var/task/dist/server/.vercel/output/functions/_render.func/dist/server/entry.mjs',
  code: 'ERR_MODULE_NOT_FOUND'
}
Node.js process exited with exit status: 1. The logs above can help with debugging the issue.

What's the expected result?

I should be able to see the entire project live because the astro config complies exactly with everyting I've researched and it should be a working device.

I've tried several combinations but the one docs stick to is this:

  output: 'server',
  adapter: vercel(),

Have tried the following:

  output: 'server',
  adapter: vercel({
    includeFiles: ['.vercel/output/functions/_render.func/dist/server/entry.mjs'],
  }),
  output: 'server',
  adapter: vercel(),
  build: {
    serverEntry: '.vercel/output/functions/_render.func/dist/server/entry.mjs',
  },
  output: 'server',
  adapter: vercel({
    analytics: true,
    webAnalytics: {
      enabled: true,
    },
    runtime: 'nodejs18.x',
    mode: 'serverless'
  }),

As i understand it, whenever i run a local build Astro should generate 2 folders inside the dist, "server" and "client" but this does not happen so everytime Vercel wants to build the application it fails to find "entry.mjs" which should be inside dist/server.

Researching the ERR_MODULE_NOT_FOUND problem, i've found is dealt by specifying the file extension when one is importing a file. For example, instead of importing "astro", it should be "astro.js"

Since this is happening outside of my application, at build time/when it gets deployed, I feel this is out of my reach and cannot do much about that entry.mjs file other than to switch the path to it somewhere.

I don't think the reproducible example is of any worth since you would need to deploy it to Vercel but its there as it was mandatory.

Link to Minimal Reproducible Example

https://stackblitz.com/github/withastro/astro/tree/latest/examples/basics?file=astro.config.mjs

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Feb 22, 2025
@eduardonwa
Copy link
Author

This does include "server" after build but it does not translate to Vercel.

  output: 'server',
  adapter: vercel({
    includeFiles: ['dist/server//*'],
  }),

The tail end of the build message:

22:06:47 [@astrojs/vercel] Bundling function ../../../../dist/server/entry.mjs
ENOENT: no such file or directory, realpath '/root/code/mois/dist/server//*'
  Stack trace: 

If i try and make a commit with it, the build log within vercel outputs this:

Error: Config file was not found at "/vercel/path0/.vercel/output/config.json"
at oP (/var/task/sandbox.js:675:115)
at async lYt (/var/task/sandbox.js:687:1917)
at async X3i (/var/task/sandbox.js:704:8024)
at async J3i (/var/task/sandbox.js:704:7825)

@florian-lefebvre
Copy link
Member

Your minimal reproduction is just the basics example, not an actual reproduction. You need to update it with what causes the issue (or make a new public repo if you prefer)

@florian-lefebvre florian-lefebvre added needs repro Issue needs a reproduction and removed needs triage Issue needs to be triaged labels Feb 22, 2025
Copy link
Contributor

Hello @eduardonwa. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with needs repro will be closed if they have no activity within 3 days.

@eduardonwa
Copy link
Author

Your minimal reproduction is just the basics example, not an actual reproduction. You need to update it with what causes the issue (or make a new public repo if you prefer)

heres the repo: https://github.com/eduardonwa/noserverastro

tried to deploy it yet again to vercel and got the same response. added a readme with more detail about the problem. repo uses node18 as that's the version vercel supports (my dashboard also uses this version)

vercel url: https://gojira-psi.vercel.app/

Image

error log of this repo:

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/var/task/dist/server/entry.mjs' imported from /opt/rust/nodejs.js
    at new NodeError (node:internal/errors:405:5)
    at finalizeResolution (node:internal/modules/esm/resolve:332:11)
    at moduleResolve (node:internal/modules/esm/resolve:1029:10)
    at moduleResolveWithNodePath (node:internal/modules/esm/resolve:876:12)
    at defaultResolve (node:internal/modules/esm/resolve:1255:79)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:404:12)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:373:25)
    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:250:38)
    at ModuleLoader.import (node:internal/modules/esm/loader:336:34)
    at importModuleDynamically (node:internal/modules/cjs/loader:1256:33) {
  url: 'file:///var/task/dist/server/entry.mjs',
  code: 'ERR_MODULE_NOT_FOUND'
}
Node.js process exited with exit status: 1. The logs above can help with debugging the issue.

@florian-lefebvre florian-lefebvre added needs triage Issue needs to be triaged and removed needs repro Issue needs a reproduction labels Feb 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

2 participants