![](/img/trans.png)
[英]SyntaxError: The requested module 'sqlite' does not provide an export named 'default'
[英]Consuming jquery using importmap gives error "The requested module 'jquery' does not provide an export named 'default'"
我编写了一个对 JQuery 具有对等依赖的模块。
我正在尝试从香草 JS 应用程序访问它,但收到以下错误:
未捕获的语法错误:请求的模块“jquery”未提供名为“default”的导出
组件中的第一行(它已经通过汇总)是:
import e from 'jquery'
我在香草 JS 中有一个导入映射,我从以下位置调用它:
<script type="importmap">
{
"imports": {
"jquery":"https://code.jquery.com/jquery-3.6.0.min.js"
}
}
</script>
然后我包含一个模块:
<script type="module" src="/js/shim.js"></script>
其中 shim.js 包含:
import { setSubscriptionLevel, setAjaxUrl, initializeCarousels } from './carousel.js'
这失败了。
事实上,以下在 shim.js 中也失败了:
import e from 'jquery'
尽管以下两项均成功:
import * as $ from 'jquery';
import e from 'https://code.jquery.com/jquery-3.6.0.min.js';
有任何想法吗?
谢谢!
jQuery 并不意味着作为 ESM 导入。
这就是为什么,即使以下工作:
<script type="importmap">
{
"imports": {
"jquery": "https://code.jquery.com/jquery-3.6.0.min.js"
}
}
</script>
<script type="module">
import 'jquery';
console.log($);
console.log(jQuery);
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.