# Cannot use jsroot in next.js (React)

**URL:** <https://root-forum.cern.ch/t/cannot-use-jsroot-in-next-js-react/59493>\
**Category:** ROOT\
**Tags:** jsroot\
**Created:** [May 28, 2024, 2:08pm UTC](https://root-forum.cern.ch/t/cannot-use-jsroot-in-next-js-react/59493 "2024-05-28T14:08:14Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![wiso](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wiso/32/11120_2.png) [@wiso](https://root-forum.cern.ch/u/wiso)\
**Post date:** [May 28, 2024, 2:08pm UTC](https://root-forum.cern.ch/t/cannot-use-jsroot-in-next-js-react/59493/1 "2024-05-28T14:08:14Z")

</div>

I have a web application using [next.js](https://nextjs.org/) (a React framework)

This is my simple component page.tsx

```auto
import { openFile } from 'jsroot';

export default function ExamplePage() {
    let file = openFile('public/myfile.root');
    return (
        <> </>
    );
}

```

I get

```auto

Module not found: Can't resolve 'gl'

https://nextjs.org/docs/messages/module-not-found

Import trace for requested module:
./node_modules/jsroot/modules/hist/TH2Painter.mjs
./node_modules/jsroot/modules/main.mjs
./src/app/example/page.tsx
```

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [May 28, 2024, 2:10pm UTC](https://root-forum.cern.ch/t/cannot-use-jsroot-in-next-js-react/59493/2 "2024-05-28T14:10:12Z")

</div>

I’m sure @linev can help you

---

<div class="post-metadata">

**Author:** ![linev](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/2bfe46/32.png) [@linev](https://root-forum.cern.ch/u/linev)\
**Post date:** [May 28, 2024, 2:18pm UTC](https://root-forum.cern.ch/t/cannot-use-jsroot-in-next-js-react/59493/3 "2024-05-28T14:18:26Z")

</div>

Did you try to call `npm install gl`?

---

<div class="post-metadata">

**Author:** ![wiso](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wiso/32/11120_2.png) [@wiso](https://root-forum.cern.ch/u/wiso)\
**Post date:** [May 28, 2024, 2:23pm UTC](https://root-forum.cern.ch/t/cannot-use-jsroot-in-next-js-react/59493/4 "2024-05-28T14:23:01Z")

</div>

Sure, that is what I was doing, but I wanted to undestand the problem since if I run a node interactive session everything works, e.g.

```auto
node

const { openFile } = await import("jsroot");
openfile('myroot.root');

```

Installing gl works, but then I hit the next dependency

```auto
Module not found: Can't resolve 'fflate'

```

---

<div class="post-metadata">

**Author:** ![linev](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/2bfe46/32.png) [@linev](https://root-forum.cern.ch/u/linev)\
**Post date:** [May 28, 2024, 2:27pm UTC](https://root-forum.cern.ch/t/cannot-use-jsroot-in-next-js-react/59493/5 "2024-05-28T14:27:44Z")

</div>

Normally `npm` install all necessary dependency automatically.

Only if you are using `npm install --production` flag some extra dependencies will be skipped.

---

<div class="post-metadata">

**Author:** ![wiso](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wiso/32/11120_2.png) [@wiso](https://root-forum.cern.ch/u/wiso)\
**Post date:** [May 28, 2024, 2:28pm UTC](https://root-forum.cern.ch/t/cannot-use-jsroot-in-next-js-react/59493/6 "2024-05-28T14:28:35Z")

</div>

I am installing with npm install jsroot.

---

<div class="post-metadata">

**Author:** ![linev](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/2bfe46/32.png) [@linev](https://root-forum.cern.ch/u/linev)\
**Post date:** [May 28, 2024, 2:55pm UTC](https://root-forum.cern.ch/t/cannot-use-jsroot-in-next-js-react/59493/7 "2024-05-28T14:55:05Z")

</div>

Looks like `npm` does not install “devDependencies” from jsroot any longer.

To use all jsroot functions one need “gl”, “fflate” and several other modules.  
Please try to install them “by hand”

“gl” was removed from normal dependencies some time ago because of install problems on several platforms. Meanwhile problem is resolved - may be I need to add it again.

---

<div class="post-metadata">

**Author:** ![wiso](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wiso/32/11120_2.png) [@wiso](https://root-forum.cern.ch/u/wiso)\
**Post date:** [May 28, 2024, 9:10pm UTC](https://root-forum.cern.ch/t/cannot-use-jsroot-in-next-js-react/59493/8 "2024-05-28T21:10:48Z")

</div>

everything works if I resolve the dependencies manually

---

<div class="post-metadata">

**Author:** ![linev](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/2bfe46/32.png) [@linev](https://root-forum.cern.ch/u/linev)\
**Post date:** [May 29, 2024, 8:05am UTC](https://root-forum.cern.ch/t/cannot-use-jsroot-in-next-js-react/59493/9 "2024-05-29T08:05:40Z")

</div>

I will add missing dependency to the next jsroot release 7.7.1

---

<div class="post-metadata">

**Author:** ![wiso](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wiso/32/11120_2.png) [@wiso](https://root-forum.cern.ch/u/wiso)\
**Post date:** [May 29, 2024, 8:41am UTC](https://root-forum.cern.ch/t/cannot-use-jsroot-in-next-js-react/59493/10 "2024-05-29T08:41:50Z")

</div>

thanks a lot!

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [June 12, 2024, 8:42am UTC](https://root-forum.cern.ch/t/cannot-use-jsroot-in-next-js-react/59493/11 "2024-06-12T08:42:36Z")

</div>

Closed on June 12, 2024, 8:42am UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
