About design and nearby

Working with Angular: how to fix “Cannot find name ‘require'” issue

Posted: November 15th, 2017 | Author: | Filed under: Development, Tips and Tricks | Tags: , , | 1 Comment »

Sometimes building an app with Angular 4.. after including file in component and compiling, you can get such type of error:

Cannot find name ‘require’.

I have the following in one of my components:

angular component error issue

And it’s fixed by adding a magic line – to satisfy the Typescript compiler, you will need to tell it that System is an acceptable variable by declaring it:

declare var require: any;

angular 'require' fix

That’s it!

Share Button

Check Related Posts:

One Comment on “Working with Angular: how to fix “Cannot find name ‘require'” issue”

  1. 1 Olamibo O. Johnvict said at 4:13 am on January 10th, 2019:
    Reply  |  Quote

    Thanks a lot. This saved me a ton of codes


Leave a Reply


  • nine − = 1

Looking for a Freelance UX & UI designer for your project? I’m ready to jump onboard!

Let's discuss your project now