Vite解决报错(Top-level await is not available in the configured target environment)

这篇具有很好参考价值的文章主要介绍了Vite解决报错(Top-level await is not available in the configured target environment)。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

Vite解决报错(Top-level await is not available in the configured target environment),node,javascript,前端,node.js,vue.js

项目在用vite打包时报错
报错信息:“Top-level await is not available in the configured target environmen“ 翻译 “顶级等待在配置的目标环境中不可用”

解决问题

  1. npm安装vite-plugin-top-level-await插件
npm install vite-plugin-top-level-await -D
  1. 配置vite.config.js文件
import topLevelAwait from 'vite-plugin-top-level-await'

之后在plugins中添加topLevelAwait方法

plugins: [
    topLevelAwait({
      promiseExportName: '__tla',
      promiseImportName: i => `__tla_${i}`
    })
  ],

最后重新打包即可
Vite解决报错(Top-level await is not available in the configured target environment),node,javascript,前端,node.js,vue.js文章来源地址https://www.toymoban.com/news/detail-694832.html

到了这里,关于Vite解决报错(Top-level await is not available in the configured target environment)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 【异常解决】The coordinator is not available

    最近上线跑了一个flink任务,运行不久,就会挂掉,初步查看日志报错如下 报错原因为The coordinator is not available. 报错在网上搜了一下,根据网友的经验,是消费组协调leader不存在导致 查看kafka __consumer_offsets topic 发现确实有Leader:none的 可能原因是 __consumer_offset topic的默认分区

    2024年02月09日
    浏览(42)
  • 【python】linux系统python报错“ssl module in Python is not available”

    pip安装时遇到openssl问题,没办法安装第三方库 “WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available. ” 直接执行python,进入python, 输入import  ssl ,也会报相似的错误。  正常情况下,是这样的,导入成功无报错 根据出错信息提示分析:

    2024年02月21日
    浏览(32)
  • ubuntu warning: gpg (GnuPG) is not available. 解决办法

    warning: gpg (GnuPG) is not available. warning: Installing it is strongly encouraged. fatal: cannot make /home/xxxx/work/dove13/.repo/repo directory: File ex kkkkcom@kkkkcom-virtual-machine:/snap/bin$ ls -l repo lrwxrwxrwx 1 root root 13 5月 16 09:38 repo - git-repo.repo kkkkcom@kkkkcom-virtual-machine:/snap/bin$ ls -l git-repo.repo lrwxrwxrwx 1 root root 1

    2024年02月15日
    浏览(39)
  • Vite+web3:报错出现ReferenceError: process is not defined

    近期使用vite脚手架搭建一个区块链项目,需要web3这个依赖库,但是在项目当中引入web3后,报错出现:  解决方案是在vite配置文件vite.config.js当中配置: 然后正常引入即可:

    2024年02月12日
    浏览(57)
  • keil 报错 *** Target ‘Target 1‘ uses ARM-Compiler ‘Default Compiler Version 5‘ which is not available

    问题:*** Target ‘Target 1’ uses ARM-Compiler ‘Default Compiler Version 5’ which is not available. 这个错误是由于使用的 ARM 编译器“Default Compiler Version 5”不可用导致。 原因是新版的keil不在自动下载v5版本的编译器,但是老版本使用的v5,所以需要手动安装v5的编译器。下载v5.06的编译器并

    2024年02月05日
    浏览(26)
  • ReferenceError: require is not defined 【vue3 +vite +setup语法使用报错】

    原本我们在vue2时代,可以使用require 导入静态资源,如下所示 但在vue3中的vite没有require方法定义的使用,说白了就是不使用require方法进行资源的导入,而是使用新的方法。详情请看官网。 Vite官网 我这里提供两种方法: 方法1: 使用 import导入资源 方法2: 直接使用 new URL(

    2024年02月13日
    浏览(32)
  • 【Ubuntu升级报错】“the following signatures couldn’t be verified because the public key is not available”

    在ubuntu中运行apt-get update时,有时会出现如下报错 如果不去解决,无法继续进行后续的升级操作 这是由apt包系统的安全机制引起的问题,有时系统无法包含所有的key。此处有快速修复的办法,即将缺少的key加进去即可。 观察里面的报错,其实是4EB27DB2A3B88B8B( 请注意,每个人

    2024年02月12日
    浏览(53)
  • 解决:javax.websocket.server.ServerContainer not available 报错问题

    在 SpringBoot 项目中集成了 WebSocket,当进行 SpringBoot 单元测试时报错: 报错的方法是: 报错的方法的主要作用是: 用于扫描带有 @ServerEndpoint 的注解成为 websocket ,该方法是 服务器端点出口,当进行 SpringBoot 单元测试时,并没有启动服务器,所以当加载到这个bean时会报错。

    2024年02月16日
    浏览(27)
  • windows: pip install 报错SSLError Can‘t connect to HTTPS URL because the SSL module is not available

    windows anaconda pip清华源 通过pip install 安装不成功,会报错(Caused by SSLError(\\\"Can\\\'t connect to HTTPS URL because the SSL module is not available.\\\")) 错误详情如下: 具体是什么错误什么原因导致,不去深究了。或许是源本身有问题?下面直接提供解决方法,通过更换源解决了该错误 加上--truste

    2024年02月15日
    浏览(35)
  • [kafka] 消费没有数据的问题解决Group coordinator lookup failed: The coordinator is not available

    [kafka] 消费没有数据的问题解决Group coordinator lookup failed: The coordinator is not available 目录 前言 一、解决问题 在项目中使用了kafka,生产者可以正常的往里放数据,但是消费者无法获取数据,通过kafka命令获取也无法获取,观察控制台发现,报了如下错误。 排查发现topic中没有

    2024年02月07日
    浏览(27)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包