udecode / plate

The rich-text editor for React.
https://platejs.org
Other
9.16k stars 609 forks source link

Compilation Error with '@udecode/plate-core' and 'nanoid/non-secure' in React App #2940

Open erseversahin opened 5 months ago

erseversahin commented 5 months ago

I'm integrating PlateJS into my React application using create-react-app and @craco/craco. However, I encounter a compilation error with @udecode/plate-core:

Failed to compile.

./node_modules/@udecode/plate-core/dist/index.mjs
Attempted import error: 'nanoid' is not exported from 'nanoid/non-secure' (imported as 'nanoid2').

I've confirmed 'nanoid' is installed, deleted node_modules and package-lock.json, and reinstalled dependencies. I've also tried different versions of 'nanoid' and ensured all related packages are up to date. My project uses craco for configuration.

craco.config.js:

const CracoAlias = require('craco-alias');

module.exports = {
    plugins: [
        {
            plugin: CracoAlias,
            options: {
                source: 'tsconfig',
                baseUrl: './src',
                tsConfigPath: './tsconfig.paths.json'
            },
        },
    ],
}

Environment:

React: ^18.2.0 react-dom: ^18.2.0 Any suggestions for resolving this issue would be greatly appreciated.

Funding

Fund with Polar

Zrs0105 commented 1 month ago

yes,i have same error,how to resolve.