#Astro 5 error

4 messages · Page 1 of 1 (latest)

edgy gyro
#

Since upgrading to astro 5, building gives the error:

x Build failed in 652ms
[commonjs--resolver] [plugin vite:resolve] Cannot bundle Node.js built-in "node:path" imported from "node_modules/@astrojs/markdown-remark/dist/import-plugin-default.js". Consider disabling environments.ssr.noExternal or remove the built-in dependency.

supple oarBOT
#

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

#

This error you're encountering after upgrading to Astro 5 is related to changes in how Node.js built-in modules are handled. Astro 5 has made some changes to improve compatibility with different runtime environments, which can affect how certain Node.js modules are imported and processed.

To resolve this issue, you have a couple of options:

  1. Update your import statements:
    Astro 5 encourages using the node: prefix for Node.js built-in modules. You might need to update your import statements to use this prefix. For example:

    import path from 'node:path';
    

    Astro Imports Reference (https://docs.astro.build/en/guides/imports/#node-builtins) provides more information on this.

  2. Adjust your Vite configuration:
    You may need to modify your Vite configuration to externalize the node:path module. Add the following to your astro.config.mjs file:

    export default defineConfig({
      // ... other config options
      vite: {
        ssr: {
          external: ['node:path']
        }
      }
    });
    

    This change is based on the information from the Astro v5 Upgrade Guide (https://docs.astro.build/en/guides/upgrade-to/v5/#changed-js-dependencies-in-config-file-are-no-longer-processed-by-vite).

If these solutions don't resolve your issue, it's possible that you're using a package or integration that hasn't been updated for Astro 5 compatibility. In that case, you might need to check for updates to your dependencies or consult the specific package's documentation for Astro 5 compatibility.

#

Remember to check the Astro v5 Known Issues (https://docs.astro.build/en/guides/upgrade-to/v5/#known-issues) for any reported problems that might match your situation. If you continue to face issues, consider filing an issue on the Astro GitHub repository.

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