question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

craco-antd and react-scripts 5.0.0

See original GitHub issue

Not compatible with react-scripts 5.0.0 😥 https://www.npmjs.com/package/react-scripts/v/5.0.0

yarn start output

(node:81909) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'push' of undefined
    at Object.overrideWebpackConfig (app/node_modules/craco-less/lib/craco-less.js:141:34)
    at Object.overrideWebpackConfig (app/node_modules/craco-antd/lib/craco-antd.js:64:26)
    at overrideWebpack (app/node_modules/@craco/craco/lib/features/plugins.js:42:40)
    at app/node_modules/@craco/craco/lib/features/plugins.js:64:29
    at Array.forEach (<anonymous>)
    at applyWebpackConfigPlugins (app/node_modules/@craco/craco/lib/features/plugins.js:63:29)
    at mergeWebpackConfig (app/node_modules/@craco/craco/lib/features/webpack/merge-webpack-config.js:110:30)
    at overrideWebpackDev (app/node_modules/@craco/craco/lib/features/webpack/override.js:11:36)
    at app/node_modules/@craco/craco/scripts/start.js:27:5
(Use `node --trace-warnings ...` to show where the warning was created)
(node:81909) UnhandledPromiseRejectionWarning: Unhandled promise rejection. 
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise 
which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag 
`--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:81909) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections 
that are not handled will terminate the Node.js process with a non-zero exit code.

my package.json

  "devDependencies": {
    "@craco/craco": "^6.4.3",
    "craco-alias": "^3.0.1",
    "craco-antd": "^1.19.0",
    "craco-sass-resources-loader": "^1.1.0",
    "typescript": "^4.5.2"
  }

my craco.config.js (only 3 plugins)

// * Craco docs
// * https://github.com/gsoft-inc/craco/blob/master/packages/craco/README.md
// * Plugins
const CracoAntDesignPlugin = require('craco-antd');
const sassResourcesLoader = require('craco-sass-resources-loader');
const CracoAlias = require('craco-alias');

const path = require('path');

const pathResolve = (pathUrl) => path.join(__dirname, pathUrl);

module.exports = {
  reactScriptsVersion: 'react-scripts',

  // Don't reorder plugins
  plugins: [
    {
      // https://www.npmjs.com/package/craco-antd
      plugin: CracoAntDesignPlugin,
      options: {
        customizeThemeLessPath: pathResolve('./src/styles/antd/theme.less'),
      },
    },
    {
      // https://www.npmjs.com/package/craco-sass-resources-loader
      plugin: sassResourcesLoader,
      options: {
        resources: './src/styles/core.scss',
      },
    },
    {
      // https://www.npmjs.com/package/craco-alias
      plugin: CracoAlias,
      options: {
        source: 'tsconfig',
        // baseUrl SHOULD be specified
        // plugin does not take it from tsconfig
        baseUrl: './',
        // tsConfigPath should point to the file where "baseUrl" and "paths" are specified
        tsConfigPath: './tsconfig.extend.json',
      },
    },
  ],
};

I commented CracoAntDesignPlugin & tried re-run yarn start and my app was built/ran correctly.

My temporary fix:

returned to version "react-scripts": "4.0.3" I will wait for updates. Thanks

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:4
  • Comments:5

github_iconTop GitHub Comments

0reactions
kamronbatmancommented, Apr 21, 2022

Should be working now. Let’s open a new issue ticket if there are still issues.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Craco does not work properly with react-scripts@5.0.0
After upgrading react-scripts to v5, craco start does not work properly. App starts with no error but in browser, there is a blank...
Read more >
craco-less 2.0.0 requires react-scripts 5 but that's incompatible ...
I can't seem to find versions of react-scripts and craco that are compatible with both craco-less 2.0.0 and each other. craco 6.4.3 requires ......
Read more >
Use in create-react-app - Ant Design
We can achieve that by using craco which is one of create-react-app's custom config solutions. Install craco and modify the scripts field in...
Read more >
You need to update your react-script package. As craco@6.4 ...
Portable Document Format (PDF) - developed 30 years ago still exists and is one of the most...
Read more >
craco-less examples - CodeSandbox
Learn how to use craco-less by viewing and forking craco-less example apps on CodeSandbox. ... ant-design/create-react-app-antd.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found