Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReferenceError when external resources loaded #38

Open
Bastorx opened this issue Sep 13, 2019 · 1 comment
Open

ReferenceError when external resources loaded #38

Bastorx opened this issue Sep 13, 2019 · 1 comment

Comments

@Bastorx
Copy link

Bastorx commented Sep 13, 2019

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;
@Bastorx
Copy link
Author

Bastorx commented Sep 13, 2019

Almost fixed when add

If (typeof $ !== "undefined")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant