The console swears at the path to the registration file. Checked all registers and paths. Everything is correct, but the error is still there
import express from 'express';
import bodyParser from 'body-parser';
import mongoose from 'mongoose';
import ReactDOMServer from 'react-dom/server';
import Registration from './src/components/Registration/Registration';
const app = express();
const PORT = 5000;
// Парсинг JSON-данных из запросов
app.use(bodyParser.json());
// Подключение к MongoDB
mongoose.connect('mongodb://localhost:27017/registration', {
useNewUrlParser: true,
useUnifiedTopology: true,
});
const connection = mongoose.connection;
connection.once('open', () => {
console.log('Connected to MongoDB');
});
const userSchema = new mongoose.Schema({
username: String,
email: String,
password: String,
});
const User = mongoose.model('User', userSchema);
// Обработка запроса на регистрацию
app.post('/register', async (req, res) => {
const { username, email, password } = req.body;
try {
const user = new User({
username,
email,
password,
});
await user.save();
res.send('User registered successfully');
} catch (error) {
res.status(500).send(error.message);
}
});
app.get('/Registration', (req, res) => {
const component = ReactDOMServer.renderToString(Registration);
const html = `
<!DOCTYPE html>
<html>
<head>
<title>Registration Page</title>
</head>
<body>
<div id="root">${component}</div>
<script src="/static/bundle.js"></script>
</body>
</html>
`;
res.send(html);
});
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}`);
});
The path to the registration form as soon as I did not register, the console gives an error Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'c:\\Users\dell\Desktop\miningmonsters\src\components\Registration\Registration' imported from C:\Users\dell\Desktop\miningmonsters\server.js
I can't figure out what's wrong
Tried everything that is possible. I changed paths, tried to prescribe through require. Help, I've been racking my brain all day