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

160
Visualizações
Using impoted js method returns ..._WEBPACK_IMPORTED_MODULE_0___default(...) is not a function

I'm using external lib. I added it to package.json:

dependencies: {
    ...
    "hello-world": "0.0.1",
    ...
}

This lib exports one method

index.js:

const helloWorld = (name: string) => {
  ...
}
window.helloWorld = window.helloWorld || helloWorld;
export default helloWorld;

Now, Im trying to use that in my Angular project. I added src/types.d.ts:

declare module 'hello-world';

and tsconfig.json:

  ...
  "files": [
    "types.d.ts"
  ]

Then in app.component.ts:

...
import helloWorld from 'hello-world';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit {


  ngOnInit(): void {
    helloWorld('Bob');
  }
}

But im getting: ERROR TypeError: hello_world__WEBPACK_IMPORTED_MODULE_0___default(...) is not a function Importing it like import { helloWorld } from 'hello-world'; gives the same error.

However when i call window.helloWorld('Bob') in debugger console (F12) it works.

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