Javascript-форум (https://javascript.ru/forum/)
-   Node.JS (https://javascript.ru/forum/node-js-io-js/)
-   -   ERROR in ./src/pages/Shop.js 5:0-71 Module not found: Error: Can't resolve (https://javascript.ru/forum/node-js-io-js/85032-error-src-pages-shop-js-5-0-71-module-not-found-error-can%27t-resolve.html)

riaron86 12.03.2023 18:16

ERROR in ./src/pages/Shop.js 5:0-71 Module not found: Error: Can't resolve
 
ERROR in ./src/pages/Shop.js 5:0-71
Module not found: Error: Can't resolve 'C:/education/reactjs/src/components/itemlist.js' in 'C:\education\reactjs\src\pages'

webpack compiled with 1 error and 1 warning
вот сам код

riaron86 12.03.2023 18:49

Как пофиксить?

Nexus 12.03.2023 19:54

Цитата:

Сообщение от riaron86
Module not found: Error: Can't resolve 'C:/education/reactjs/src/components/itemlist.js'

Цитата:

Сообщение от riaron86
Как пофиксить?

:-?
Проверить, что файл существует по указанному пути и, в случае его отсутствия, либо добавить его, либо исправить путь к этому файлу.

riaron86 13.03.2023 07:10

index.js:
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';


const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
    <App />
);

App.js:
import React from 'react';

import Shop from './pages/Shop.js';
function App() {
  return (
    <div className="App">
      <Shop/>
    </div>
  );
}

export default App;

Shop.js
import React from 'react';
import Itemslist from '../components/itemslist.js';

const Shop = () => {
    return (
        <div>
            <Itemslist/>
        </div>
    );
};

export default Shop;

itemslist.js:
import React from 'react';
import Item from './item.js';
const Itemslist = () => {
    return (
        <div>
            <item id={'1'} text={'hello world'}/>
        </div>
    );
};

export default Itemslist;

item.js
import React from 'react';

const Item = ({text}) => {
    return (
        <div>
            {text}
        </div>
    );
};

export default Item;

ошибок не выдыет hello world не выводит

ksa 13.03.2023 09:31

Цитата:

Сообщение от riaron86
ошибок не выдыет hello world не выводит

Тебе нужно повышать внимательность... :write:
Цитата:

Сообщение от riaron86
import Item from './item.js';

Цитата:

Сообщение от riaron86
<item id={'1'} text={'hello world'}/>

Так же всегда можно посмотреть что именно нагенерилось в самом браузере... ;)


Часовой пояс GMT +3, время: 14:08.