[英]./src/index.js Module not found: Can't resolve '~antd/dist/antd.css'
我遇到了问题。/src/index.js 找不到模块:无法解析 '~ antd / dist / antd.css',我无法修复它。 我试着把@import '~ antd / dist / antd.css'; . 在 CSS 文件中。 没有成功。
包.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"
]
}
}
@import '~antd/dist/antd.css';
如果您使用 -> npx create-react-app yourAppName
启动您的应用程序
不要import 'antd/dist/antd.css';
进入你的index.js
会失败!!!
不要使用GET STARTED DOCS
而是使用在此处找到的Use in create-react-app
中使用
@import '~antd/dist/antd.css';
到App.css
文件的顶部import { Button } from 'antd';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.