Quantcast
Channel: Active questions tagged rest - Stack Overflow
Viewing all articles
Browse latest Browse all 4802

How to use import in JavaScript while using Spring Boot

$
0
0

I ve been looking for a way to use import Chart from 'chart.js/auto' in my webpage. Im currently using Spring Boot, with Thymeleaf.

Problem is, none of the things I tried worked. I have a node_modules inside my Static resources, and I cant seem to load the scripts from there.

If I try to just import my JS using<script th:src="@{/js/graficaLoader.js}"></script> it just saysCannot use import statement outside a module

If I import using type=module, thenUncaught TypeError: Failed to resolve module specifier "chart.js/auto". Relative references must start with either "/", "./", or "../".

I cant really store all my scripts inside the own html, I need separate files for doing things and its driving me mad.

I tried looking for this exact thing and I can however find info about it. I just started Web Development after being focused on Java for around a year.


Viewing all articles
Browse latest Browse all 4802

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>