jwt регистрация выдает ошибку связанную с uuid
jwt регистрация выдает ошибку cdz
npm run dev npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead. > server@1.0.0 dev > nodemon index.js [nodemon] 3.1.11 [nodemon] to restart at any time, enter `rs` [nodemon] watching path(s): *.* [nodemon] watching extensions: js,mjs,cjs,json [nodemon] starting `node index.js` [dotenv@17.2.3] injecting env (8) from .env -- tip: ✅ audit secrets and track compliance: https://dotenvx.com/ops C:\jwt\server\service\user-service.js:3 const uuid=require('uuid'); ^ Error [ERR_REQUIRE_ESM]: require() of ES Module C:\jwt\server\node_modules\uuid\dist-node\index.js from C:\jwt\server\service\user-service.js not supported. Instead change the require of index.js in C:\jwt\server\service\user-service.js to a dynamic import() which is available in all CommonJS modules. at Object.<anonymous> (C:\jwt\server\service\user-service.js:3:12) at Object.<anonymous> (C:\jwt\server\controllers\user-controller.js:1:19) at Object.<anonymous> (C:\jwt\server\router\index.js:2:22) at Object.<anonymous> (C:\jwt\server\index.js:7:15) { code: 'ERR_REQUIRE_ESM' } [nodemon] app crashed - waiting for file changes before starting... во т код uzser-service
const {UserSchema} = require('../models/models');
const bcrypt=require('bcrypt');
const uuid=require('uuid');
const mailService=require('./mail-service');
const tokenService=require('./token-service');
const UserDto=require('../dtos/user-dto');
class UserService {
async registration(email,password){
const candidate = await UserSchema.findOne({where: {email}});
if(candidate){
throw new Error(`Пользователь с почтовым адресом ${email} уже существует`);
}
const hashPassword = await bcrypt.hash(password, 5)
const activationLink=uuid.v4();
const user = await UserSchema.create({email,password: hashPassword,activationLink,role:'user'});
await mailService.sendActivationMail(email,activationLink);
const userDto=new UserDto(user);
const tokens=tokenService.generateTokens({...userDto});
await tokenService.saveToken(userDto.id,tokens.refreshToken);
return{
...tokens,
user:userDto
}
}
}
module.exports=new UserService();
|
что за ES модуль и почему не устанавливается
пишет npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead. npm ERR! code E404 npm ERR! 404 Not Found - GET https://registry.npmjs.org/ES - Not found npm ERR! 404 npm ERR! 404 'ES@*' is not in this registry. npm ERR! 404 This package name is not valid, because npm ERR! 404 1. name can no longer contain capital letters npm ERR! 404 npm ERR! 404 Note that you can also install from a npm ERR! 404 tarball, folder, http url, or git url. npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\фвьшт\AppData\Local\npm-cache\_logs\2025-11-30T11_36_12_966Z-debug-0.log PS C:\jwt\server> npm i ES Module npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead. npm ERR! code E404 npm ERR! 404 Not Found - GET https://registry.npmjs.org/ES - Not found npm ERR! 404 npm ERR! 404 'ES@*' is not in this registry. npm ERR! 404 This package name is not valid, because npm ERR! 404 1. name can no longer contain capital letters npm ERR! 404 npm ERR! 404 Note that you can also install from a npm ERR! 404 tarball, folder, http url, or git url. npm ERR! A complete log of this run can be found in: npm ERR! |
| Часовой пояс GMT +3, время: 16:53. |