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

543
Visualizações
How can I use timers/promises from Node 16 in a Typescript project?

In Node 16 release, there's new timers/promises API that I want to use. I installed Node 16 with NVM and switched to it:

$ nvm use       
Found '/Users/golergka/Projects/my-project/.nvmrc' with version <16>
Now using node v16.0.0 (npm v7.10.0)

And even added engines to my package.json:

"engines": { "node": ">=16" }

I wasn't sure if I needed to install version 16 of @types/node, but I tried (without success):

npm install --save-dev @types/node@16
npm ERR! code ETARGET
npm ERR! notarget No matching version found for @types/node@16.
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.

For now, I have ^14.14.41 installed.

And finally, I tried to import setTimeout in my Typescript file:

import { setTimeout } from 'timers/promises'

But got an error:

Cannot find module 'timers/promises' or its corresponding type declarations.

How can I fix this?

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

It has been published 3 days ago, in @types/node. Just run npm install --save-dev @types/node@latest, or yarn add --dev @types/node@latest. The version is 0.

over 4 years ago · Santiago Trujillo Relatório

0

Currently the node types are outdated, you can only turn off the error with ts ignore

over 4 years ago · Santiago Trujillo Relatório
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