【问题标题】:Errors in next.config.js with next-compose-plugins package带有 next-compose-plugins 包的 next.config.js 中的错误
【发布时间】:2022-11-01 19:10:50
【问题描述】:

Next.js 为我的 next.config.js 文件向我抛出与 next-compose-plugins 相关的错误。我不确定为什么?我已经尝试重新安装所有节点包。

错误: “根值有一个意外的属性,webpackDevMiddleware” “根值有一个意外的属性,configOrigin,” “根值有一个意外的属性,目标,” “根值有一个意想不到的属性,webpack5,” “TypeError:无法设置未定义的属性‘样式’”

  /** @type {import('next').NextConfig} */ const nextConfig = {   
reactStrictMode: true,   swcMinify: true, };
 
const withCSS = require("@zeit/next-css");    
const withFonts =require("next-fonts");    
const withImages = require("next-images"); 
const withPlugins = require("next-compose-plugins");

module.exports = withPlugins([withCSS, withFonts, withImages], 
nextConfig);

【问题讨论】:

  • 你不需要next-compose-plugins@zeit/next-css 已经被弃用很久了(Next.js 已经内置了对 CSS 的支持)。确保您的软件包是最新的,并尝试将配置重写为module.exports = withFonts(withImages(nextConfig));

标签: reactjs next.js


【解决方案1】:

由于Next moved to SWC,next-compose-plugins 将无法工作。相反,您必须像这样嵌套您的配置: https://github.com/vercel/next.js/discussions/11162

【讨论】:

    猜你喜欢
    • 2021-04-11
    • 2020-04-20
    • 2022-06-14
    • 2021-09-20
    • 2021-10-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-26
    相关资源
    最近更新 更多