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

im getting a few errors when deploying on github #9

Open
katesgo opened this issue Feb 21, 2024 · 1 comment
Open

im getting a few errors when deploying on github #9

katesgo opened this issue Feb 21, 2024 · 1 comment

Comments

@katesgo
Copy link

katesgo commented Feb 21, 2024

Invalid next.config.js options detected:
⚠ Unrecognized key(s) in object: 'images' at "experimental"

Failed to compile.

./node_modules/canvas/build/Release/canvas.node

Import trace for requested module:
./node_modules/canvas/build/Release/canvas.node
./node_modules/canvas/lib/bindings.js
./node_modules/canvas/index.js
./node_modules/jsdom/lib/jsdom/utils.js
./node_modules/fabric/dist/fabric.js
./lib/canvas.ts
./app/App.tsx

Build failed because of webpack errors

even after updating the next.config.mjs and adding environment variable... please help!

@getFrontend
Copy link

To fix this problem, You have to make sure you're using the ssr option set to false:

So you page.tsx shold be:

import dynamic from "next/dynamic";

const App = dynamic(() => import("./App"), { ssr: false });

export default App;

and in App.tsx move all the code that was there before to page.tsx

And make sure that your next.config.mjs has a webpack config options for canvas:

/** @type {import('next').NextConfig} */
const nextConfig = {
  webpack: (config) => {
    config.externals.push({
      "utf-8-validate": "commonjs utf-8-validate",
      bufferutil: "commonjs bufferutil",
      canvas: "commonjs canvas",
    });
    return config;
  },
  images: {
    remotePatterns: [
      {
        protocol: "https",
        hostname: "liveblocks.io",
        port: "",
      },
    ],
  },
  typescript: {
    ignoreBuildErrors: true,
  },
};

export default nextConfig;

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

2 participants