[英]./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.