#Cannot find module @rollup/rollup-linux-x64-gnu

4 messages · Page 1 of 1 (latest)

sharp shoal
#

I'm building an Astro 5 website that uses middleware. On localhost it works fine. When deployed on Netlify, it fails and server log says : Cannot find module @rollup/rollup-linux-x64-gnu. Without middleware, no error on Netlify. Please help 🙂

shut ravenBOT
#

Hi @sharp shoal. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

This issue appears to be related to deploying an Astro site with middleware on Netlify. Based on the information provided in the knowledge sources, I can offer some insights and potential solutions:

  1. First, ensure you have properly set up the Netlify adapter for your Astro project. The Netlify adapter guide provides instructions on how to install and configure the adapter.

  2. When using middleware with Netlify, you need to enable the edgeMiddleware option in your Astro configuration. This allows your middleware to run on Netlify Edge Functions. Here's how you can do that:

import { defineConfig } from 'astro/config';
import netlify from '@astrojs/netlify';

export default defineConfig({
  output: 'server',
  adapter: netlify({
    edgeMiddleware: true,
  }),
});
  1. The error message "Cannot find module @rollup/rollup-linux-x64-gnu" suggests there might be an issue with the build process or dependencies. Make sure you have the latest version of the Netlify adapter installed and that your package.json includes all necessary dependencies.

  2. If the issue persists, you may want to check your Netlify build settings. Ensure that the build command and publish directory are correctly set:

    • Build command: astro build or npm run build
    • Publish directory: dist
  3. If you're using a specific Node.js version locally, make sure to specify the same version in your Netlify deployment settings. You can do this by adding a .nvmrc file to your project or setting the NODE_VERSION environment variable in your Netlify project dashboard.

#

If these steps don't resolve the issue, you may need to create a minimal reproduction of the problem and seek further assistance. The Astro documentation on creating minimal reproductions provides guidance on how to do this effectively.

Remember, when deploying with middleware, the edgeMiddleware option is crucial for proper functionality on Netlify. If you continue to experience issues, consider reaching out to Netlify support or the Astro community for more specific help.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: