1

I want to use javascript npm module in django template.

In javascript document, it says

npm install waveform-playlist --save on cli

and to use this line in code.

import WaveformPlaylist from "waveform-playlist";

So, for now I write this script in template.html

<script>
import WaveformPlaylist from "waveform-playlist";
</script>

this error comes.

 Cannot use import statement outside a module (at tracks:96:5)

I think some basic idea is wrong?

How can I use this type of javascript?

whitebear
  • 11,200
  • 24
  • 114
  • 237
  • you may want to take a look at https://stackoverflow.com/questions/51325809/django-how-to-use-npm-modules-with-static-templates and https://stackoverflow.com/questions/70089451/how-can-i-use-npm-modules-with-django-inside-an-app – Carlo Jul 29 '22 at 10:18
  • 1
    Thank you very much , I decided to use webpack – whitebear Jul 30 '22 at 14:55

0 Answers0