Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

157
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!