Ray Hulha
Ray Hulha

Reputation: 11221

How can I use jQuery UI (jqueryui) with StackBlitz and TypeScript and NPM

I am trying to use jQuery UI in StackBlitz.

I am also trying to install it as a dependency and without a script tag.

I understand that I have to add @types/jquery and @types/jqueryui as dependencies.

But when I add this in the index.ts

import $ from "jquery";
import "jqueryui";

I get the error: "jQuery is not defined"

Upvotes: 0

Views: 1008

Answers (1)

Ray Hulha
Ray Hulha

Reputation: 11221

This code seems to do the trick:

import $ from "jquery";
declare var global: any
global.jQuery = $;
import "jqueryui";

Here is a screenshot of the dependencies:

enter image description here

Upvotes: 2

Related Questions