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

159
Vistas
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 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