تابستون داره تموم میشه ها، فرصت‌ها محدودن کلی آفر جذاب در کمپین تابستون🔥👇
۰ ثانیه
۰ دقیقه
۰ ساعت
۴ منصور عبادیان
عدم اجرای کد
جامعه ری اکت ایجاد شده در ۲۴ خرداد ۱۴۰۲

سلام

کدی که نوشتم خطای زیر را میده. این مربوط به reat 18 یا ورژن پایین webpack نیست؟

0] Failed to compile.

[0]

[0] Module not found: Error: Can't resolve 'url' in 'C:\\Users\\user\\Desktop\\react\\54\\simple-blog\\node_modules\\hookrouter\\dist'

[0] BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.

[0] This is no longer the case. Verify if you need this module and configure a polyfill for it.

[0]

[0] If you want to include a polyfill, you need to:

[0]   - add a fallback 'resolve.fallback: { "url": require.resolve("url/") }'

[0]   - install 'url'

[0] If you don't want to include a polyfill, you can use an empty module like this:

[0]   resolve.fallback: { "url": false }

[0] ERROR in ./node_modules/hookrouter/dist/router.js 76:14-28

[0] Module not found: Error: Can't resolve 'url' in 'C:\\Users\\user\\Desktop\\react\\54\\simple-blog\\node_modules\\hookrouter\\dist'

[0] 

[0] BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.

[0] This is no longer the case. Verify if you need this module and configure a polyfill for it.

[0]

[0] If you want to include a polyfill, you need to:

[0]   - add a fallback 'resolve.fallback: { "url": require.resolve("url/") }'

[0]   - install 'url'

[0] If you don't want to include a polyfill, you can use an empty module like this:

[0]   resolve.fallback: { "url": false }

[0]

[0] webpack compiled with 1 error

این هم کلاس App که مطابق فیلم نوشتم:

import { useRoutes } from "hookrouter";

import BlogPage from "./pages/BlogPage";

import HomePage from "./pages/HomePage";

import PostPage from "./pages/PostPage";

import NotFoundPage from "./pages/NotFoundPage";

const routes={

  '/':()=><HomePage />,

  '/blog':()=><BlogPage />,

  '/post/:id':({id})=><PostPage id={id} />

}

function App() {

  const match=useRoutes(routes)

  return match||<NotFoundPage />

}

export default App;

سلام

بنظر میرسد که شما از webpack ورژن پایین استفاده می‌کنید.

آدرس زیر را مطالعه کنید.

موفق باشید

مریم علی شاهی ۲۴ خرداد ۱۴۰۲، ۱۸:۴۷

همچنان هم ارور زیر رو میده

ERROR in ./node_modules/hookrouter/dist/router.js 76:14-28

Module not found: Error: Can't resolve 'url' in 'C:\\Users\\user\\Desktop\\react\\54\\simple-blog\\node_modules\\hookrouter\\dist'


BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.

This is no longer the case. Verify if you need this module and configure a polyfill for it.


If you want to include a polyfill, you need to:

- add a fallback 'resolve.fallback: { "url": require.resolve("url/") }'

- install 'url'

If you don't want to include a polyfill, you can use an empty module like this:

resolve.fallback: { "url": false }

منصور عبادیان ۲۶ خرداد ۱۴۰۲، ۰۶:۲۱

من پکیج url رو نصب کردم درست شد اما چرا برای React 18 تمام این پکیج‌ها رو باید با --force نصب کرد ؟


منصور عبادیان ۲۶ خرداد ۱۴۰۲، ۱۵:۳۹

سلام،

چون ممکنه با dependency‌ها و بسته‌های قبلی conflict پیدا کنه، شما باید با این فلگ تعیین کنید در هر شرایطی میخواهید عملیات انجام شود.

بهترین پاسخ
محسن موحد ۲۶ خرداد ۱۴۰۲، ۱۸:۲۳