Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

179
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda