PNotify: SyntaxError: import not found: defaultModules

PNotify: SyntaxError: import not found: defaultModules

我正尝试在 thymeleaf html 页面上使用 PNotify 在网络浏览器上显示一个简单的通知。

我已将以下 webjar 添加到我的 pom.xml。

<dependency>
        <groupId>org.webjars.npm</groupId>
        <artifactId>pnotify__core</artifactId>
        <version>${pnotify.version}</version>
</dependency>
<dependency>
        <groupId>org.webjars.npm</groupId>
        <artifactId>pnotify__mobile</artifactId>
        <version>${pnotify.version}</version>
</dependency>

PNotify 版本 = 5.2.0

在我的 HTML 中,我包含了 -

<link th:href="@{/webjars/pnotify__core/dist/PNotify.css}" rel="stylesheet" />
<link th:href="@{/webjars/pnotify__mobile/dist/PNotifyMobile.css}" rel="stylesheet" />
<script th:src="@{/webjars/pnotify__core/dist/PNotify.js}"></script>
<script th:src="@{/webjars/pnotify__mobile/dist/PNotifyMobile.js}"></script>

我已确认所有这些资源都已正确加载,状态代码为 200。 在我的 javascript 中,我正在尝试执行以下操作-

<script type="module">
    import { defaultModules } from '../webjars/pnotify__core/5.2.0/dist/PNotify.js';
</script>

但是,我在浏览器控制台中收到以下错误

Uncaught SyntaxError: import not found: defaultModules

我已通过检查浏览器确认该文件存在于 http://localhost:8080/webjars/pnotify__core/5.2.0/dist/PNotify.js

我一无所知,在论坛上找不到任何帮助。 有人可以帮助我并分享一些调试指南吗?

最后,我通过进行以下更改使其正常工作。 pom.xml 中的依赖关系是相同的。在 HTML 文件中,添加了以下 css 和 js

<link th:href="@{/webjars/pnotify__core/dist/PNotify.css}" rel="stylesheet" />
<link th:href="@{/webjars/pnotify__bootstrap4/dist/PNotifyBootstrap4.css}" rel="stylesheet" />
<script th:src="@{/webjars/pnotify__core/dist/PNotify.js}"></script>
<script th:src="@{/webjars/pnotify__bootstrap4/dist/PNotifyBootstrap4.js}"></script>

在 javascript 中,使用了以下代码片段(没有任何导入)

PNotify.defaultModules.set(PNotifyBootstrap4, {});
PNotify.success({
    title: 'Success!',
    text: 'That thing that you were trying to do worked.'
});