Reputation: 57
I have the issue ./src/index.js Module not found: Can't resolve '~ antd / dist / antd.css', I can not fix it. I tried to put the @import '~ antd / dist / antd.css'; . In css file. Without success.
package.json:
{
"name": "time-clock",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.11.6",
"@testing-library/react": "^11.2.2",
"@testing-library/user-event": "^12.5.0",
"antd": "^4.9.2",
"firebase": "^8.1.2",
"polished": "^4.0.5",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-scripts": "4.0.1",
"styled-components": "^5.2.1",
"web-vitals": "^0.2.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
Upvotes: 4
Views: 23313
Reputation: 1
In file index.js
import { ConfigProvider, theme } from 'antd';
Wrap the App tag like this:
<ConfigProvider theme={{
algorithm: theme.darkAlgorithm
}}>
<App />
</ConfigProvider>
Upvotes: 0
Reputation: 9364
@import '~antd/dist/antd.css';
if you started your app with -> npx create-react-app yourAppName
don't import 'antd/dist/antd.css';
into your index.js
it will fail !!!
DO NOT USE THE GET STARTED DOCS
Instead use the Use in create-react-app
found here
@import '~antd/dist/antd.css';
to the top of App.css
fileimport { Button } from 'antd';
Upvotes: 9