提问人:Ирина Грачева 提问时间:8/2/2022 最后编辑:Drew ReeseИрина Грачева 更新时间:8/2/2022 访问量:1229
无法解决 mui 中的“react/jsx-runtime”,react 18
Can't resolve 'react/jsx-runtime' in mui, react 18
问:
当我通过 yarn start 启动应用程序时,无法解析 react 版本 18.2.0 和 mui 版本 5.9.3 的 mui 包中的“react/jsx-runtime” 我启动应用程序 vi cross-env
cross-env NODE_ENV=development webpack serve --config webpack.dev.config.js --progress
我正在使用 React.FC:
import { Select } from "@mui/material";
import MenuItem from "@mui/material/MenuItem";
import React from "react";
const products = [
"123",
"234,
"345",
"567",
"678",
];
export const App: React.FC = () => {
return (
<>
<Select
value={"value"}
onChange={() => console.log("React")}
label="ProductId"
>
{ products.map((product, index) => {
return (
<MenuItem key={index} value={product}>
{product}
</MenuItem>
);
})}
</Select>
</>
);
};
export default App;
我有package.json:
...
"@emotion/react": "^11.10.0",
"@emotion/styled": "^11.10.0",
"@mui/icons-material": "^5.8.4",
"@mui/material": "^5.9.3",
"react": "^18.2.0",
"react-device-detect": "^2.1.2",
"react-dom": "^18.2.0",
"react-hot-loader": "^4.13.0",
"react-jss": "^10.9.0"
...
我有tsconfig.json:
"include": ["src", "tests"],
"exclude": ["**/node_modules"],
"compilerOptions": {
"resolveJsonModule": true,
"rootDir": "./src",
"sourceRoot": "./src",
"declaration": false,
"types": ["jest", "node"],
"allowSyntheticDefaultImports": true,
"emitDecoratorMetadata": false,
"experimentalDecorators": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"noFallthroughCasesInSwitch": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"noImplicitOverride": true,
"noUnusedParameters": true,
"pretty": true,
"removeComments": true,
"sourceMap": true,
"strictNullChecks": true,
"stripInternal": true,
"target": "esnext",
"jsx": "react-jsx",
"lib": ["esnext", "dom"],
"strict": true
我有一个错误:
Module not found: Error: Can't resolve 'react/jsx-runtime' in '/Users/igracheva/dpa-ui/app/node_modules/@mui/material/Select'
我的react js无法正常启动。它写了一个错误“无法解析'react/jsx-runtime'”
答: 暂无答案
评论
yarn
yarn start
npm install