После npm start
браузер выдает ошибку:
Не удалось скомпилировать ./src/components/App/App.js Модуль не найден: Не удается разрешить 'response-router-dom '.
React-router-dom был добавлен к зависимостям в npm, равно как иагирующий маршрутизатор, и реакция.
Проект создан с использованием строки create-react-app myapp
cmd.Это выполняется на локальном узле, сервере узлов.У меня есть папка api и app внутри папки моего проекта.Я пробовал разные вещи.Обновил вручную мой package.json в папке приложения, переустановил response-router-dom, удалил package-lock.json в папке приложения и повторно инициализировал его.В моей папке api нет ничего, кроме node_modules, моего api-файла, route.js, config.js, index.js, а также package.json и package-lock.json.Я попробовал команду сборки npm в папке моего приложения.Он просто создает папку «build», которая содержит те же файлы, что и моя общая папка, внутри папки моего приложения.Я также попытался запустить yarn add react-router-dom
.
//=========App.js file=========
//dependencies
import React, { Component } from 'react';
import { BrowserRouter as Router, Route } from 'react-router-dom';
//components
import Header from '../Header/Header';
import Footer from '../Footer/Footer';
import Home from '../Pages/Home';
import StudentOverview from '../Pages/StudentOverview';
import StudentDetails from '../Pages/StudentDetails';
import Management from '../Pages/Management';
import StudentAdd from '../Pages/StudentAdd';
import Exercise from '../Exercise/Exercise';
//includes
import '../../../public/css/kdg-fonts.css';
import '../../../public/css/normalize.css';
import '../../../public/css/responsive.css';
import '../../../public/css/say-my-name.css';
import '../../../public/css/style.css';
//Run
class App extends Component {
render() {
return (
<Router>
<div className="App">
<Route path='*' component={Header} />
<Route path='*' component={Footer} />
<Route exact path='/' component={Home} />
<Route exact path='/studenten' component={StudentOverview} />
<Route exact path='/studenten/:id' component={StudentDetails} />
<Route exact path='/beheer' component={Management} />
<Route exact path='/beheer/add' component={StudentAdd} />
<Route exact path='/oefenen' component={Exercise} />
</div>
</Router>
);
}
}
export default App;
//=========appfolder/package.json file=========
{
"name": "saymyname",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.7.0",
"react-dom": "^16.7.0",
"react-scripts": "2.1.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
],
"devDependencies": {
"gulp": "^4.0.0",
"gulp-changed": "^3.2.0",
"gulp-clean-css": "^4.0.0",
"gulp-rename": "^1.4.0",
"gulp-sass": "^4.0.2",
"gulp-uglify": "^3.0.1"
}
}
ОБНОВЛЕНИЕ: npm install -S react-router-dom
устранил ошибку.