# Unable to import vtk libraries.

**URL:** https://discourse.vtk.org/t/unable-to-import-vtk-libraries/12013
**Category:** vtk.js
**Tags:** vtkjs
**Created:** [July 25, 2023, 7:29am UTC](https://discourse.vtk.org/t/unable-to-import-vtk-libraries/12013 "2023-07-25T07:29:21Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![sunita](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sunita/32/7519_2.png) [@sunita](https://discourse.vtk.org/u/sunita)
#### Post date: [July 25, 2023, 7:29am UTC](https://discourse.vtk.org/t/unable-to-import-vtk-libraries/12013/1 "2023-07-25T07:29:21Z")

</div>

Dear VTK Team,

We are trying to use vtk.js as suggested in the following link.

> **[Using vtk.js as an ES dependency](https://kitware.github.io/vtk-js/docs/intro_vtk_as_es6_dependency.html)**
>
> This guide illustrates how to consume vtk.js as an ES dependency. This document was last updated with the following package versions: @kitware/vtk.js@v19 webpack@v5 Starting a new vtk.js projectTher

However, we are unable to import vtk libraries.

Could you please answer why is so?

Thank you so much for the help.

Best regards,  
Sunita

---

<div class="post-metadata">

### Author: ![Sebastien\_Jourdain](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sebastien_jourdain/32/100_2.png) [@Sebastien\_Jourdain](https://discourse.vtk.org/u/Sebastien_Jourdain)
#### Post date: [July 25, 2023, 4:55pm UTC](https://discourse.vtk.org/t/unable-to-import-vtk-libraries/12013/2 "2023-07-25T16:55:39Z")

</div>

You will have to provide more information of what you did that is not working.

Nowadays, it is better and simpler to import the ESM module (@kitware/vtk-js/… ) so you don’t have to play with transpiler rules of your build system.

---

<div class="post-metadata">

### Author: ![sunita](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sunita/32/7519_2.png) [@sunita](https://discourse.vtk.org/u/sunita)
#### Post date: [July 26, 2023, 1:45pm UTC](https://discourse.vtk.org/t/unable-to-import-vtk-libraries/12013/3 "2023-07-26T13:45:39Z")

</div>

Hi Sebastien,

We are beginners. We followed the tutorials as given. However, got following errors.

Could you please guide us explicitly on how to rectify it. We want to display vtp file of the tumor as 3D and we have generated vtp file from the medical images.

These are the steps we followed to do this.

Step 1: We have created a project folder and installed @kitware/vtk.js using npm. It created a node module folder.

Step 2: We created a HTML page in project folder and imported vtk.js script tag as given in the following example.

import ‘./node\_modules/@kitware/vtk.js/Rendering/Core/RenderWindow’

 ![vtkjs](https://discourse.vtk.org/uploads/default/original/2X/f/f96cef4c8c441a321431acd15da67ec979642118.jpeg)

When we executed the script we got following error.

 ![error](https://discourse.vtk.org/uploads/default/original/2X/4/434cde29c7d5941c6e0073fbf7b67acd129dbfe6.jpeg)

If we add type = “module” in script tag we get following error.

 ![error2](https://discourse.vtk.org/uploads/default/original/2X/5/5b35d52126d13043f26cacf1fb50be3db1ac2b2a.jpeg)

Please help us in implementing vtk.js.

Your help will be highly appreciated.

Thank you so much.

Best regards,  
Sunita

---

<div class="post-metadata">

### Author: ![Sebastien\_Jourdain](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sebastien_jourdain/32/100_2.png) [@Sebastien\_Jourdain](https://discourse.vtk.org/u/Sebastien_Jourdain)
#### Post date: [July 26, 2023, 11:35pm UTC](https://discourse.vtk.org/t/unable-to-import-vtk-libraries/12013/4 "2023-07-26T23:35:57Z")

</div>

What you are doing is indeed not right. If you just want to write JavaScript in HTML directly without a build step you should look at [that guide](https://kitware.github.io/vtk-js/docs/intro_vtk_as_external_script.html).

Otherwise you will have to learn how to develop with JavaScript and a bundler (webpack, vite, …). The VTK community can not teach you that part.

---

<div class="post-metadata">

### Author: ![sunita](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sunita/32/7519_2.png) [@sunita](https://discourse.vtk.org/u/sunita)
#### Post date: [July 28, 2023, 1:37pm UTC](https://discourse.vtk.org/t/unable-to-import-vtk-libraries/12013/5 "2023-07-28T13:37:13Z")

</div>

Hi Sebastien,

Thank you so much for your help. We didn’t know that vtk.js implementation requires webpack. Now we could figure it out. It’s working.

Here is the image we built using webpack.

 ![tumor](https://discourse.vtk.org/uploads/default/original/2X/6/651a96c68edf942e7145cbfffb25a3039a324fd8.jpeg)

Your guidance helped to built this.

Thanks again.

Best regards,  
Sunita

---

<div class="post-metadata">

### Author: ![ranjeet\_aey](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/r/c37758/32.png) [@ranjeet\_aey](https://discourse.vtk.org/u/ranjeet_aey)
#### Post date: [August 9, 2023, 12:18pm UTC](https://discourse.vtk.org/t/unable-to-import-vtk-libraries/12013/6 "2023-08-09T12:18:46Z")

</div>

Is there any example how we can include vtk.js in an existing project(vite bundler is used).

---

<div class="post-metadata">

### Author: ![Sebastien\_Jourdain](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sebastien_jourdain/32/100_2.png) [@Sebastien\_Jourdain](https://discourse.vtk.org/u/Sebastien_Jourdain)
#### Post date: [August 9, 2023, 7:06pm UTC](https://discourse.vtk.org/t/unable-to-import-vtk-libraries/12013/7 "2023-08-09T19:06:31Z")

</div>

If you use the ESM package, there is nothing to do.
