当前位置: 首页 > 知识库问答 >
问题:

我创建了一个React项目,当我下载数据包时,遇到了以下错误

师建德
2023-03-14

./src/App。less(./node_modules/css loader/dist/cjs.js??ref--5-oneOf-8-1!。/node_modules/postss loader/src??postss!。/node_modules/resolve url loader??ref--5-oneOf-8-4!。/src/App less)类型错误:此。getOptions不是一个函数

// package.json
{
  "name": "demo_react",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.11.4",
    "@testing-library/react": "^11.1.0",
    "@testing-library/user-event": "^12.1.10",
    "antd": "^4.15.0",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-scripts": "4.0.3",
    "web-vitals": "^1.0.1"
  },
  "scripts": {
    "start": "react-app-rewired start",
    "build": "react-app-rewired build",
    "test": "react-app-rewired 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"
    ]
  },
  "devDependencies": {
    "babel-plugin-import": "^1.13.3",
    "customize-cra": "^1.0.0",
    "less": "^4.1.1",
    "less-loader": "^8.0.0",
    "react-app-rewire-less": "^2.1.3",
    "react-app-rewired": "^2.1.8"
  }
}
// config-overrides.js
const { override, fixBabelImports, addLessLoader } = require('customize-cra');

module.exports = override(
    fixBabelImports('import', {
        libraryName: 'antd',
        libraryDirectory: 'es',
        style: true
    }),
    addLessLoader({
        lessOptions: {
            javascriptEnabled: true,
            modifyVars: {}
        }
    })
);

共有1个答案

濮阳耀
2023-03-14

从项目中删除您的node_modules文件夹,并运行此命令npm安装,然后运行您的项目

 类似资料: