Closed dajun1230 closed 3 years ago
如果可以,我们可以加qq,我把项目代码发你,因为只是我搭建为了配置这个快捷菜单而写的项目
附上 qq: 1123395547
Sorry, I don't understand you. But as far as I see, you have a craco
error here and also there is a warning that should not affect the workability. If you can't start the application, it's worth looking for a solution to that craco
problem.
当我按照案例配置好各个文件的时候,发现项目都启动不了? 另外就是在引用过程中,vscode中也是弹出红色警告,贴出代码 craco.config.js如下: const CracoLessPlugin = require('craco-less'); const CracoAlias = require("craco-alias");
module.exports = { plugins: [ { plugin: CracoLessPlugin, options: { lessLoaderOptions: { lessOptions: { modifyVars: { '@primary-color': '#1DA57A' }, javascriptEnabled: true, }, }, }, }, { plugin: CracoAlias, options: { source: "tsconfig", baseUrl: "./src", tsConfigPath: "./tsconfig.extend.json" } } ] }; tsconfig.json如下: { "extends": "./tsconfig.extend.json", "compilerOptions": { "target": "es5", "lib": [ "dom", "dom.iterable", "esnext" ], "allowJs": true, "skipLibCheck": true, "esModuleInterop": true, "allowSyntheticDefaultImports": true, "strict": true, "forceConsistentCasingInFileNames": true, "noFallthroughCasesInSwitch": true, "module": "esnext", "moduleResolution": "node", "resolveJsonModule": true, "isolatedModules": true, "noEmit": true, "jsx": "react" }, "include": [ "src" ] } tsconfig.extend.json如下: { "compilerOptions": { "baseUrl": "./src", "paths": { "@src": ["./"] } } } 此时package.json文件如下: { "name": "antd-demo-ts", "version": "0.1.0", "private": true, "dependencies": { "@craco/craco": "^5.8.0", "@testing-library/jest-dom": "^5.11.4", "@testing-library/react": "^11.1.0", "@testing-library/user-event": "^12.1.10", "@types/jest": "^26.0.15", "@types/node": "^12.0.0", "@types/react": "^16.9.53", "@types/react-dom": "^16.9.8", "add": "^2.0.6", "antd": "^4.8.2", "craco-alias": "^2.1.1", "craco-less": "^1.17.0", "react": "^17.0.1", "react-dom": "^17.0.1", "react-loadable": "^5.5.0", "react-redux": "^7.2.2", "react-router-dom": "^5.2.0", "react-scripts": "4.0.0", "redux": "^4.0.5", "typescript": "^4.0.3", "web-vitals": "^0.2.4", "yarn": "^1.22.10" }, "scripts": { "start": "craco start", "build": "craco build", "test": "craco test" }, "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" ] } }
出现的问额如下:
TypeError: Cannot add property paths, object is not extensible at verifyTypeScriptSetup (/Users/xiaoyang/Documents/allProjects/demos/antd-demo-ts/node_modules/react-scripts/scripts/utils/verifyTypeScriptSetup.js:239:43) at Object. (/Users/xiaoyang/Documents/allProjects/demos/antd-demo-ts/node_modules/react-scripts/scripts/start.js:31:1)
并且我引用如下import Routes from '@src/config/routes';也会报错,请问一下,怎么解决