首页 > 解决方案 > TypeError:“编译”参数必须是 Shopify 中的编译实例

问题描述

我做shopify反应教程。但是 MyApp 显示了这个错误。

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

我该如何解决?

包裹 版本
节点 15.9.0
npm 7.5.3
1.22.10
@shopify/koa-shopify-auth ^3.2.8
@shopify/北极星 ^6.0.1
@zeit/next-css ^1.0.1
dotenv ^8.2.0
同构提取 ^3.0.0
考阿 ^2.13.1
koa会话 ^6.1.0
下一个 ^10.0.7
反应 ^17.0.1
反应域 ^17.0.1
网页包 ^5.23.0

这是我的代码。

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;

标签: reactjsnext.jsshopifyshopify-api

解决方案


您可以删除 next.config.js 文件,它会按预期工作。教程很旧。Next.js 在 v 10 中支持 css。


推荐阅读