Closed Pearce-Ropion closed 3 years ago
Is neo-async
a package you're using? Can you run yarn why neo-async
to see what package depends on it? If you're using it, can you try removing it?
@sidharthachatterjee Im definitely not using neo-async directly. It looks like it is used in a couple of gatsby packages.
=> Found "neo-async@2.6.2"
info Reasons this module exists
- "sass-loader" depends on it
- Hoisted from "sass-loader#neo-async"
- Hoisted from "webpack#neo-async"
- Hoisted from "@storybook#cli#jscodeshift#neo-async"
- Hoisted from "gatsby-plugin-sass#sass-loader#neo-async"
- Hoisted from "webpack#watchpack#neo-async"
- Hoisted from "babel-plugin-react-docgen#react-docgen#neo-async"
- Hoisted from "@storybook#react#webpack#neo-async"
- Hoisted from "gatsby#webpack#neo-async"
- Hoisted from "gatsby-plugin-netlify-cms#webpack#neo-async"
- Hoisted from "@storybook#cli#@storybook#codemod#jscodeshift#neo-async"
- Hoisted from "@storybook#react#@storybook#core#webpack#neo-async"
- Hoisted from "@storybook#react#@storybook#core#corejs-upgrade-webpack-plugin#webpack#neo-async"
info Disk size without dependencies: "752KB"
info Disk size with unique dependencies: "752KB"
info Disk size with transitive dependencies: "752KB"
info Number of shared dependencies: 0
Also our storybook is built separately so we can remove all references to storybook as suspect from the list above as well as babel-plugin-react-docgen
which is also used for our storybook.
Edit: Had another quick look and we use sass-loader
as well as webpack
directly but also only in our storybook. Otherwise any webpack
usage comes from gatsby.
I just confirmed that this issue pertains specifically to gatsby-plugin-netlify-cms
. I tried removing the plugin from the gatsby-config
and re-building and was able to build just fine.
I think the issue may have something to do with how the CSS is handled in gatsby-plugin-netlify-cms
. I found this thread:
https://stackoverflow.com/questions/61799995/running-webpack-throws-callback-was-already-called-error
Which states that the css shouldn't be <link>
'd to but rather imported. Unfortunately Im not really sure how the plugin is getting the correct assets into place.
I can confirm that our implementation does import scss directly into our cms.js file which is then handled by gatsby-plugin-sass
and exported as cms.css
which is then picked up by netlify-cms and registered correctly.
https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-plugin-netlify-cms/src/cms.js#L25
I've read some of gatsby-plugin-netlify-cms
's code and know that it messes around with the CSS rules in the onCreateWebpackConfig quite a bit so something in there might be the culprit.
Here is a snippet of our cms.js file just in case
import CMS from "netlify-cms-app";
import "typeface-lato";
import "typeface-inconsolata";
import config from "cms/config";
import { BASE_URL } from "config";
import "scss/global.scss";
import "./cms.scss";
global.___loader = {
enqueue: () => {},
hovering: () => {},
};
global.__PATH_PREFIX__ = "";
window.___navigate = pathname => {
alert(`This would navigate to: https://www.${BASE_URL}${pathname}`);
};
CMS.init({
config,
});
I was able to fix this. Although I never found the exact cause, I believe it has to do with version mismatches between the package versions of babel/webpack loaders that were in my package.json
and the versions that gatsby specifies. I believe it was specifically due to css-loader
which was a full major version ahead in our site.
I fixed this by going through the package.json
of each of the gatsby packages that we use and matching any babel/webpack loader's versions.
@Pearce-Ropion I can confirm that your description is accurate:
gatsby-plugin-netlify-cms
the error goes away, but I need it, so<link/>
declarations@Pearce-Ropion still no luck, which css packages you have?
@Pearce-Ropion I can confirm that your description is accurate:
if I disable
gatsby-plugin-netlify-cms
the error goes away, but I need it, soI enabled it back but removed all css/scss imports and the error went away, so something to do with sass loader was the
reason
I removed all
<link/>
declarationsdowngraded to node-sass to 4.12 since i was using node 12
@Pearce-Ropion still no luck, which css packages you have?
Basically this problem occurs due to a mismatch in package versions between the packages required in your package.json and the packages required by by any of the other packages that your project uses. Specifically the packages that are used for building (webpack, sass, etc)
I've actually experienced this problem twice now (the second time was about a month after I closed this issue). Here are a few of the things that I found that you should watch out for:
Ultimately, I still believe that the 2 times this happened were separate errors (ie. unrelated errors that attempted to call the same callback fn) but overall, managing the versions of babel/webpack/webpack loaders in order to make them at least resemble the versions used in gatsby and any other build processes you have will fix this issue.
Feel free to pm me if you need more help.
Interesting, especially considering I did not have either storybook, nor was I importing any sass packages aside from the standard gatsby-plugin-sass
. Thanks a lot for coming back to me @Pearce-Ropion , how should I pm you?
jus in case, here is my setup:
package.json
{
"name": "gatsby-starter-hello-world",
"private": true,
"description": "A simplified bare-bones starter for Gatsby",
"version": "0.1.0",
"license": "0BSD",
"scripts": {
"build": "gatsby build",
"develop": "npm run clean && gatsby develop",
"format": "prettier --write \"**/*.{js,jsx,ts,tsx,json,md}\"",
"start": "npm run develop",
"serve": "gatsby serve",
"clean": "gatsby clean",
"test": "echo \"Write tests! -> https://gatsby.dev/unit-testing\" && exit 1"
},
"dependencies": {
"dart-sass": "^1.25.0",
"gatsby": "^2.32.3",
"gatsby-cli": "^2.19.1",
"gatsby-image": "^2.11.0",
"gatsby-plugin-netlify-cms": "^4.10.0",
"gatsby-plugin-react-helmet": "^3.10.0",
"gatsby-plugin-sass": "^3.2.0",
"gatsby-plugin-sharp": "^2.14.1",
"gatsby-remark-images": "^3.11.0",
"gatsby-remark-relative-images": "^2.0.2",
"gatsby-source-filesystem": "^2.11.0",
"gatsby-transformer-remark": "^2.16.0",
"gatsby-transformer-sharp": "^2.12.0",
"netlify-cms-app": "^2.14.18",
"react-helmet": "^6.1.0"
},
"repository": {
"type": "git",
"url": "https://github.com/gatsbyjs/gatsby-starter-hello-world"
},
"bugs": {
"url": "https://github.com/gatsbyjs/gatsby/issues"
}
}
/**
* Configure your Gatsby site with this file.
*
* See: https://www.gatsbyjs.org/docs/gatsby-config/
*/
require("dotenv").config({
path: `.env.${process.env.NODE_ENV}`,
})
module.exports = {
siteMetadata: {
title: 'Gatsby + Netlify CMS Starter',
siteUrl: "https://daruvisuals.com",
description:
'This repo contains an example business website that is built with Gatsby, and Netlify CMS.It follows the JAMstack architecture by using Git as a single source of truth, and Netlify for continuous deployment, and CDN distribution.',
},
plugins: [
'gatsby-plugin-sharp',
'gatsby-transformer-sharp',
{
resolve: `gatsby-transformer-remark`,
options: {
plugins: [
{
resolve: `gatsby-remark-relative-images`,
},
{
resolve: `gatsby-remark-images`,
options: {
// It's important to specify the maxWidth (in pixels) of
// the content container as this plugin uses this as the
// base for generating different widths of each image.
maxWidth: 2048,
},
},
],
},
},
'gatsby-plugin-react-helmet',
{
resolve: `gatsby-plugin-sass`,
options: {
implementation: require("dart-sass"),
},
},
{
resolve: 'gatsby-source-filesystem',
options: {
path: `${__dirname}/static/img`,
name: 'uploads',
},
},
{
resolve: 'gatsby-source-filesystem',
options: {
path: `${__dirname}/src/pages`,
name: 'pages',
},
},
{
resolve: 'gatsby-source-filesystem',
options: {
path: `${__dirname}/src/img`,
name: 'images',
},
},
{
resolve: 'gatsby-plugin-netlify-cms',
options: {
modulePath: `${__dirname}/src/cms/cms.js`,
},
},
]
}
Ok, as of now, I tried removing gatsby-plugin-sass
and used gatsby-plugin-postcss
and got the same problem still, next going through the list from here: https://blog.logrocket.com/10-gatsby-styling-methods/
update: creating a project with gatsby-starter-netlify-cms template fro a scratch and using scss files there gives same problem
After further investigation I figured that maybe indeed something is off with yoga-layout
package version here, or the way it works in conjunction with css.
I had this same issue when i cloned the gatsby-starter-netlify-cms and updated the packages (i think the break occured because of gatsby
package passed from version "^2.20.35"
to the latest "^2.32.3"
. Before the update the build did not fail.
I confirm this issue is somehow related to gatsby-plugin-netlify-cms
.
To solve the issue i removed the option of plugin gatsby-plugin-netlify-cms
from gatsby-config.js
, so instead of:
{
resolve: 'gatsby-plugin-netlify-cms',
options: {
modulePath: `${__dirname}/src/cms/cms.js`,
},
},
i went with:
'gatsby-plugin-netlify-cms',
This was the plugin module file cms.js
:
import CMS from 'netlify-cms-app'
import cloudinary from 'netlify-cms-media-library-cloudinary'
import AboutPagePreview from './preview-templates/AboutPagePreview'
import BlogPostPreview from './preview-templates/BlogPostPreview'
import ProductPagePreview from './preview-templates/ProductPagePreview'
import IndexPagePreview from './preview-templates/IndexPagePreview'
CMS.registerMediaLibrary(cloudinary)
CMS.registerPreviewTemplate('index', IndexPagePreview)
CMS.registerPreviewTemplate('about', AboutPagePreview)
CMS.registerPreviewTemplate('products', ProductPagePreview)
CMS.registerPreviewTemplate('blog', BlogPostPreview)
This way my build is OK.
Unfortunately, i can not use the module file cms.js
to configure the plugin anymore, so if anyone knows a workaround is welcome :)
Also, i'm referencing other issues spread across github which i think are related to this one: #24577 #25466
Hi, I'm running a website that is using a combination of gatsby and netlify CMS however the repo is unfortunately private. We are trying update our gatsby packages so as to use some of the new features coming out. I've updated all my gatsby packages to their latest version except for
gatsby-source-apiserver
.Description
I am seeing an error when running
gatsby build
during the Building production Javascript and CSS bundles step. After which the process completely freezes. There is noBuild Failed
message nor the does the terminal return to normal forcing me to ^C. Here's the error:My start command always runs
npx gatsby clean
first before runningnpx gatsby build
. Building the development bundle works correctly with no errors.I've found similar issues but none of their solutions have worked https://github.com/gatsbyjs/gatsby/issues/25142 https://stackoverflow.com/questions/59575264/building-gatsby-site-on-netlify-err-callback-was-already-called https://community.netlify.com/t/first-time-trying-to-deploy-netlify-cms-gatsby-starter-template-fails/12977/8
Based on the above I assume that it has something to do with
gatsby-plugin-netlify-cms
I have tried:
package-lock.json
+node_modules/
and runningnpm install
Steps to reproduce
Unfortunately I was unable to re-produce using a minimal build using the latest versions of
gatsby
andgatsby-plugin-netlify-cms
so I can only assume that it has something to do with the my environment that couldn't be replicated in the code-sandbox.My
gatsby-config.js
,gatsby-node.js
andpackage.json
are massive so I will only be posting what I believe to the relevant sections. I would be happy to post more.gatsby-config.js
gatsby-node.js
package.json
Environment