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

Error: ObjectMiddleware.register: serializer for mini-css-extract-plugin/dist/CssModule/null is already registered when using React 17 and netlify CMS #5321

Open
MartinSchere opened this issue Apr 30, 2021 · 6 comments
Labels
ssg: gatsby type: bug code to address defects in shipped code

Comments

@MartinSchere
Copy link

React 17 is causing the gatsby plugin to throw dependency erros (See #5111). A suggested workaround is:

Hi @arpitdalal, the CMS is a community project so the best way to fix this is via a contribution.
A workaround is suggested in the issue description:
image

This causes the issue above:

ERROR

ObjectMiddleware.register: serializer for mini-css-extract-plugin/dist/CssModule/null is already registered


  Error: ObjectMiddleware.register: serializer for mini-css-extract-plugin/dist/CssModule/null is already registered
  
  - ObjectMiddleware.js:182 Object.register
    [personal-blog]/[webpack]/lib/serialization/ObjectMiddleware.js:182:10
  
  - index.js:163 Function.getCssModule
    [personal-blog]/[mini-css-extract-plugin]/dist/index.js:163:34
  
  - index.js:358 MiniCssExtractPlugin.apply
    [personal-blog]/[mini-css-extract-plugin]/dist/index.js:358:44
  
  - webpack.js:74 createCompiler
    [personal-blog]/[webpack]/lib/webpack.js:74:12
  
  - webpack.js:123 create
    [personal-blog]/[webpack]/lib/webpack.js:123:16
  
  - webpack.js:147 webpack
    [personal-blog]/[webpack]/lib/webpack.js:147:32
  
  - index.js:54 f
    [personal-blog]/[webpack]/lib/index.js:54:15
  
  - start-server.ts:163 startServer
    [personal-blog]/[gatsby]/src/utils/start-server.ts:163:20
  
  - start-webpack-server.ts:44 startWebpackServer
    [personal-blog]/[gatsby]/src/services/start-webpack-server.ts:44:7
  

not finished Building development bundle - 8.991s

Describe the bug

To Reproduce

  1. Create a project with gatsby v3 and react 17
  2. Install netlify CMS and the gatsby plugin
  3. See the error

Package.json:


{
  "name": "gatsby-starter-blog",
  "private": true,
  "description": "A starter for a blog powered by Gatsby and Markdown",
  "version": "0.1.0",
  "author": "Kyle Mathews <[email protected]>",
  "bugs": {
    "url": "https://github.com/gatsbyjs/gatsby/issues"
  },
  "dependencies": {
    "@types/jest": "^26.0.23",
    "@types/react-helmet": "^6.1.1",
    "@types/react-test-renderer": "^17.0.0",
    "gatsby": "^3.3.1",
    "gatsby-plugin-feed": "^3.2.0",
    "gatsby-plugin-gatsby-cloud": "^2.2.0",
    "gatsby-plugin-google-analytics": "^3.2.0",
    "gatsby-plugin-image": "^1.2.1",
    "gatsby-plugin-manifest": "^3.2.0",
    "gatsby-plugin-netlify-cms": "^5.4.0",
    "gatsby-plugin-offline": "^4.2.0",
    "gatsby-plugin-react-helmet": "^4.2.0",
    "gatsby-plugin-react-svg": "^3.0.1",
    "gatsby-plugin-sass": "^4.4.0",
    "gatsby-plugin-sharp": "^3.2.1",
    "gatsby-remark-copy-linked-files": "^3.2.0",
    "gatsby-remark-images": "^4.2.0",
    "gatsby-remark-prismjs": "^4.2.0",
    "gatsby-remark-responsive-iframe": "^3.2.0",
    "gatsby-remark-smartypants": "^3.2.0",
    "gatsby-source-contentful": "^5.4.0",
    "gatsby-source-filesystem": "^3.2.0",
    "gatsby-transformer-remark": "^3.2.0",
    "gatsby-transformer-sharp": "^3.2.0",
    "netlify-cms-app": "^2.14.46",
    "prismjs": "^1.23.0",
    "react": "^17.0.0",
    "react-dom": "^17.0.0",
    "react-helmet": "^6.1.0",
    "react-icons": "^4.2.0",
    "sass": "^1.32.12"
  },
  "devDependencies": {
    "@babel/core": "^7.13.16",
    "babel-jest": "^26.6.3",
    "babel-preset-gatsby": "^1.4.0",
    "identity-obj-proxy": "^3.0.0",
    "jest": "^26.6.3",
    "plop": "^2.7.4",
    "prettier": "2.2.1",
    "react-test-renderer": "^17.0.2"
  },
  "homepage": "https://github.com/gatsbyjs/gatsby-starter-blog#readme",
  "keywords": [
    "gatsby"
  ],
  "license": "0BSD",
  "main": "n/a",
  "repository": {
    "type": "git",
    "url": "git+https://github.com/gatsbyjs/gatsby-starter-blog.git"
  },
  "scripts": {
    "build": "gatsby build",
    "develop": "gatsby develop",
    "format": "prettier --write \"**/*.{js,jsx,ts,tsx,json,md}\"",
    "start": "npm run develop",
    "serve": "gatsby serve",
    "clean": "gatsby clean",
    "test": "jest",
    "generate": "plop"
  }
}

This is most likely due to a dependency conflict I guess

@phipag
Copy link

phipag commented May 1, 2021

Downgrading from "gatsby-plugin-netlify-cms": "^5.4.0" to "gatsby-plugin-netlify-cms": "5.3.0" can be used as a temporary fix.

@erezrokah erezrokah self-assigned this May 3, 2021
@erezrokah
Copy link
Contributor

I believe gatsbyjs/gatsby#30526 broke this by using a different version of mini-css-extract-plugin in the plugin from the one used in Gatsby.
I think gatsbyjs/gatsby#31110 should fix it.
Per gatsbyjs/gatsby@c0b6dd9 it should be released in [email protected] and [email protected]

@martinjagodic
Copy link
Member

martinjagodic commented May 16, 2023

@MartinSchere is this still an issue with the latest Gatsby version?

@megascrapper
Copy link

@martinjagodic The issue seem to still exist with Gatsby 5.11.0. This only occurred when upgrading webpack to 5.88.2

My setup:

  • Netlify CMS version: 2.12.9
  • React version: 18.2.0
  • Gatsby version: 5.11.0
  • gatsby-plugin-netlify-cms version: 7.11.0
  • Webpack version: 5.88.2
  • Node.JS version: 18.16.0

Error message:

 ERROR  UNKNOWN

ObjectMiddleware.register: serializer for mini-css-extract-plugin/dist/CssModule/null is already registered



  Error: ObjectMiddleware.register: serializer for mini-css-extract-plugin/dist/CssModule/null is already reg
  istered
  
  - ObjectMiddleware.js:211 Object.register
    [webpack-npm-5.88.1-b68c09f1a7-726e7e05ab.zip]/[webpack]/lib/serialization/ObjectMiddleware.js:211:10
  
  - index.js:182 Function.getCssModule
    [mini-css-extract-plugin-npm-1.6.2-f19d00566e-c2c1f3d7e5.zip]/[mini-css-extract-plugin]/dist/index.js:182
    :34
  
  - index.js:389 MiniCssExtractPlugin.apply
    [mini-css-extract-plugin-npm-1.6.2-f19d00566e-c2c1f3d7e5.zip]/[mini-css-extract-plugin]/dist/index.js:389
    :44
  
  - webpack.js:76 createCompiler
    [webpack-npm-5.88.1-b68c09f1a7-726e7e05ab.zip]/[webpack]/lib/webpack.js:76:12
  
  - webpack.js:143 create
    [webpack-npm-5.88.1-b68c09f1a7-726e7e05ab.zip]/[webpack]/lib/webpack.js:143:16
  
  - webpack.js:167 webpack
    [webpack-npm-5.88.1-b68c09f1a7-726e7e05ab.zip]/[webpack]/lib/webpack.js:167:32
  
  - index.js:72 f
    [webpack-npm-5.88.1-b68c09f1a7-726e7e05ab.zip]/[webpack]/lib/index.js:72:16
  
  - start-server.ts:153 startServer
    [gatsby-virtual-0cacda6fe7]/[gatsby]/src/utils/start-server.ts:153:27
  
  - start-webpack-server.ts:38 startWebpackServer
    [gatsby-virtual-0cacda6fe7]/[gatsby]/src/services/start-webpack-server.ts:38:5
  

not finished Building development bundle - 3.978s

@glassonion1
Copy link

glassonion1 commented Sep 28, 2023

@megascrapper
I hava same issue on gatsby-plugin-netlify-cms version: 7.11.0
When I upgraded gatsby-plugin-netlify-cms to version 7.12.0, the errors disappeared.

My setup is below:

Netlify CMS version: 2.15.72
React version: 18.2.0
Gatsby version: 5.11.0
gatsby-plugin-netlify-cms version: 7.12.0

works fine.

@megascrapper
Copy link

@glassonion1 This only works when I keep the webpack version at 5.88.1. Once I upgraded webpack to any newer version I got the error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ssg: gatsby type: bug code to address defects in shipped code
Projects
None yet
Development

No branches or pull requests

6 participants