Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

176
Vistas
How to solve Typescript import module problem

I have split my code into several projects. And now trying to import the modules, located in node_modules.

import Ticker from "ticker" // Typescript not complaining
But the transpiled JS "import Ticker from "ticker;" does, module spec missing ‘./’, ‘../’ of ‘/’.

But adding "./" leads to: "Cannot find module '.ticker' or its corresponding type declarations."

import {Ticker} from "./node_modules/ticker/dist/ticker.js", results in a working application.
But Typescript complains "Could not find a declaration file for module './node_modules/ticker/dist/ticker.js'. "

Even if I use ///< reference path='node_modules/ticker/typings/ticker.d.ts' / >

The ticker project package contains

  "main": "dist/ticker.js",
  "module": "dist/ticker.js",
  "typings": "typings/ticker.d.ts",

ticker.d.ts

declare module 'ticker' {
    class Ticker {
        constructor (container:HTMLElement);
        add (htmlElem:HTMLElement):number;
    }
    export default Ticker;
}

The main project tsconfig.json contains:

    "moduleResolution": "node",
    "baseUrl": "./",
    "paths": {
      "Ticker":["/node_modules/ticker/dist/ticker.js"]
    },

I'm using only tsc and getting confused by all provided options and possibilities.

Why does VCode recognize the path "import {Ticker} from "./node_modules/ticker/ticker", pointing to the location of ticker.ts. But not "./node_modules/ticker/dist/", pointing to the ticker.js?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda