Using Preact, but module requires React - failing to deploy

214 Views Asked by At

I'm failing to deploy to Vercel. I get the error below. Is there anyway that I can get this deployed without downloading the react bundle?

Error: Cannot find module 'react'
Require stack:
- /vercel/path0/node_modules/pure-react-carousel/dist/index.cjs.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1075:15)
    at Module._load (node:internal/modules/cjs/loader:920:27)
    at Module.require (node:internal/modules/cjs/loader:1141:19)
    at require (node:internal/modules/cjs/helpers:110:18)

The line of code that is presumably causing the deployment problems is this one?

  var React=_interopDefault(require("react"))

I'm using Preact and I believe I have the settings set correctly in the Astro config file.

// ... 
import preact from '@astrojs/preact';

export default defineConfig({
  integrations: [
      // ....
      preact({ compat: true }),
  ],
  vite: {
    resolve: {
      alias: {
        '~': path.resolve(__dirname, './src'),
      },
    },
  },
});
0

There are 0 best solutions below