Skip to content

ReferenceError when external resources loaded #38

Open
@Bastorx

Description

@Bastorx

Error :

Module build failed (from ./node_modules/prerender-loader/dist/prerender-loader.js):
NonErrorEmittedError: (Emitted value instead of an instance of Error) ReferenceError: $ is not defined

In Index.html

<body>
	<div id="app"></div>
	<!-- jQuery -->
	<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
	<!-- jQuery Easing -->
	<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js"></script>
	<!-- Bootstrap -->
	<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
	<!-- Waypoints -->
	<script src="https://cdnjs.cloudflare.com/ajax/libs/waypoints/4.0.0/jquery.waypoints.min.js"></script>
	<!-- Stellar Parallax -->
	<script src="https://cdnjs.cloudflare.com/ajax/libs/stellar.js/0.6.2/jquery.stellar.min.js"></script>
	<!-- Easy PieChart -->
	<script src="https://cdnjs.cloudflare.com/ajax/libs/easy-pie-chart/2.1.6/jquery.easypiechart.js"></script>

	<!-- Global site tag (gtag.js) - Google Analytics -->
	<script async src="https://www.googletagmanager.com/gtag/js?id=UA-146273121-1"> </script>
	<script>
	window.dataLayer = window.dataLayer || [];
	function gtag(){dataLayer.push(arguments);}
	gtag('js', new Date());

	gtag('config', 'UA-146273121-1');
	</script>
</body>

In my Component :

  public componentDidMount() {
    if (!isMobile.any()) {
      $(".js-fullheight").css("height", $(window).height());
      $(window).resize(() => {
        $(".js-fullheight").css("height", $(window).height());
      });
    }
  }

The problem is, I'm loading jquery from a <script> and it's not in node_modules. Then He's saying that $ is not defined

I'm using typescript

And in my index.d.ts

declare var $: any;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions