Ant-design-pro: TypeError: /root/my-project/src/utils/Yuan.js: Duplicate declaration "React"

Created on 2 Oct 2018  ·  14Comments  ·  Source: ant-design/ant-design-pro

Hi there, has anybody else get this error when running npm run build?

I started getting error like these using v1, then I thought using v2 should solve it but it didn't.

Here is an screenshot, I'm getting the same error either in Ubuntu or MacOS, running Node 8.11 and 9.10

screen shot 2018-10-01 at 7 17 47 pm

Thanks in advance.

🤩Discussion

Most helpful comment

Running the following command the error stopped for me:

rm yarn.lock && rm -rf node_modules && yarn && yarn build

All 14 comments

Same error here

same ... :(

Running the following command the error stopped for me:

rm yarn.lock && rm -rf node_modules && yarn && yarn build

@Leocardoso94 it worked for me too. Thanks so much!

@Leocardoso94 Worked for me as well, thanks a lot!.

Still very strange, i had the same issue on a fresh install in the morning and i received the same errors. But now a fresh install works out of the box. Probably a dependency issue somewhere in the jungle that is node_modules

@arxae May be related with a webpack dependency, very strange indeed.

got the same error and a fresh yarn build doesn't work for me

Same error for me with v1.

Same error here as well - digging in the dependency hell :)

temporarily fixed by remove some unused import React, and change the name of React to others in some import React from 'react'.

guys you can delete the require.resolve('babel-plugin-react-require'), in babel-preset-umi/lib/index.js and retry building.

this plugin imports another react object into context, causing it conflict with the original one in ant design's code

guys you can delete the require.resolve('babel-plugin-react-require'), in babel-preset-umi/lib/index.js and retry building.

this plugin imports another react object into context, causing it conflict with the original one in ant design's code

Thanks! BTW, I'm wondering if there's a more graceful way to fix that? cause it may be inconvenient to delete code in CI&CD.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  ·  3Comments

Yoping picture Yoping  ·  3Comments

zhuanglong picture zhuanglong  ·  3Comments

suifan picture suifan  ·  3Comments

yaoleiroyal picture yaoleiroyal  ·  3Comments