TypeError: The 'compilation' argument must be an instance of Compilation in Shopify

Viewed 326

I do shopify react tutorial. But MyApp shown this error.

./node_modules/@shopify/polaris/dist/styles.css
TypeError: The 'compilation' argument must be an instance of Compilation

How can I fix it?

Package version
Node 15.9.0
npm 7.5.3
yarn 1.22.10
@shopify/koa-shopify-auth ^3.2.8
@shopify/polaris ^6.0.1
@zeit/next-css ^1.0.1
dotenv ^8.2.0
isomorphic-fetch ^3.0.0
koa ^2.13.1
koa-session ^6.1.0
next ^10.0.7
react ^17.0.1
react-dom ^17.0.1
webpack ^5.23.0

This is my code.

import App from 'next/app';
import Head from 'next/head';
import React from 'react';
import { AppProvider } from '@shopify/polaris';
import translations from '@shopify/polaris/locales/en.json';
import '@shopify/polaris/dist/styles.css';

class MyApp extends App {
    render() {
        const { Component, pageProps } = this.props;
        return (
            <React.Fragment>
                <Head>
                    <title>Sample App</title>
                    <meta charSet="utf-8" />
                </Head>
                <AppProvider i18n={ translations }>
                    <Component {...pageProps} />
                </AppProvider>
            </React.Fragment>
        );
    }
}

export default MyApp;
1 Answers

You can remove the next.config.js file and it will work as expected. The tutorial is old. Next.js supports css in v 10.

Related