Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

321
Views
.ts no se importa a la aplicación de reacción, ¿qué debo hacer?

ERROR en ./src/store/store.ts 4:0-50 Módulo no encontrado: Error: No se puede resolver '../services/AuthService' en 'D:\DND\dnd1\src\store'

paquete web compilado con 1 error y 4 advertencias

Traté de importar de diferentes maneras. Pero en cualquier caso, no funciona. Lo más importante es que mi reacción era originalmente un proyecto js y lo agregué archivos .ts

 import {IUser} from '../models/IUser' import {makeAutoObservable} from 'mobx' import AuthService from '../services/AuthService'; // const AuthService = require ('../services/AuthService.ts') export default class Store { user = {} as IUser; isAuth = false; constructor(){ makeAutoObservable(this) } setAuth(bool: boolean){ this.isAuth = bool } setUser(user: IUser){ this.user = user } async login(email: string, password: string){ try { const response = await AuthService.login(email, password) localStorage.setItem('token', response.data.accessToken) this.setUser(response.data.user) } catch (e) { console.log(e.response?.data?.message) } } async registration(email: string, password: string, name: string, lastname: string, surname: string){ try { const response = await AuthService.registration(email, password, name, lastname, surname) localStorage.setItem('token', response.data.accessToken) this.setUser(response.data.user) } catch (e) { console.log(e.response?.data?.message) } } async logout(){ try { const response = await AuthService.logout() localStorage.removeItem('token') this.setAuth(false) this.setUser({} as IUser) } catch (e) { console.log(e.response?.data?.message) } } }
 <script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Es difícil identificar el problema exacto sin saber cómo webpack , pero supongo que no tiene configurado un cargador para archivos TypeScript. Recomiendo agregar algo como lo siguiente a su module.exports y ver si eso resuelve su problema:

 module: { rules:[ { test: /\.ts$/, use: 'ts-loader', include: [path.resolve(__dirname, 'src')] } ], resolve: { extensions: ['.ts', '.js'], }, },
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!