我已经安装了最新的React Router dom,在package.js中它显示了
"react-router-dom": "^7.0.2"
。当我检查时npm -v react-router-dom its showing 10.9.0
。在我的代码中
import React from "react";
import ReactDOM from "react-dom";
import Header from "./components/Header";
import Body from "./components/Body";
import About from "./components/About";
import { createBrowserRouter as Router,RouterProvider } from "react-router-dom";
const AppLayout = () => {
return (
<div className="app">
<Header />
<Body />
</div>
);
};
const appRouter= createBrowserRouter ([
{
path:"/",element:<AppLayout/>,
},
{
path:"about",element:<About/>,
}
])
const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(<RouterProvider router= {appRouter} />); i am getting and error like
@parcel/core:无法解析“react-router/dom” './node_modules/react-router-dom/dist/index.mjs' D:\Namsthe 颂歌模块 eact-router-dom\dist\index.mjs:13:48 12 | //索引.ts
13 |从“react-router/dom”导入{ HydratedRouter, RouterProvider }; | ^^^^^^^^^^^^^^^^^^^^ 14 |从“react-router”导出*; 15 | 15出口 { @parcel/resolver-default: 无法从模块加载文件“./dom” “反应路由器”
任何帮助将不胜感激。