Skip to content

new UnhandledPromiseRejection(reason) #17214

@cswxzx

Description

@cswxzx

相关平台

支付宝小程序

小程序基础库: 1.x 2.x
使用框架: Vue 3

复现步骤

pnpm install -g @tarojs/cli
taro init myApp
cd myApp
pnpm install
pnpm run dev:alipay

[email protected] dev:alipay C:\project\myApp
npm run build:alipay -- --watch

[email protected] build:alipay
taro build --type alipay --watch

👽 Taro v4.0.9

Tips:

  1. 预览模式生成的文件较大,设置 NODE_ENV 为 production 可以开启压缩。
    Example:
    $ NODE_ENV=production taro build --type alipay --watch
  2. 建议开启持久化缓存功能,能有效提升二次编译速度,详情请参考: https://docs.taro.zone/docs/config-detail#cache。

启动 开发者工具-项目目录 C:\project\myApp\dist
Prebundle dependencies:
@tarojs/plugin-framework-vue3/dist/runtime
@tarojs/runtime
@tarojs/shared
@tarojs/taro

✔ Webpack
Compiled successfully in 4.22s

编译 发现入口 src/app.ts
编译 发现页面 src/pages/index/index.vue
→ Watching... [1/22/2025, 11:23:25 PM]

期望结果

能在小程序开发环境中正确运行

实际结果

小程序开发工具中出错
Starting dev server...
env
os win32-x64
cpu 8 cores
memory 49022.04 MB (use 4144.00 MB)
compiler
version 0.107.0
engine 5
paths
C:\project\myApp\dist
output C:\Users\xxx\AppData\Local\Temp_volans_temp_\mini_ide_dists\e61f0\ng-main
build
watch on
cache on (7867c71f)
parallel on (4 workers)
minify off
sourcemap on (script style, lazy)
javascript babel 6 (es6)
runtime
sdk 2.x
subpackage off
devserver
apiserver on (6600)
connection on
hmr off
lazy off

node:internal/process/promises:389
new UnhandledPromiseRejection(reason);
^

UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "TypeError: Cannot read properties of null (reading '_source')
at Object.normalize (C:\snapshot\builder\node_modules@ali\antcube-build\lib\build\webpack\plugin\issues\errors\not-found.js:1:806)
at C:\snapshot\builder\node_modules@ali\antcube-build\lib\build\webpack\plugin\issues\index.js:1:1622
at C:\snapshot\builder\node_modules@ali\antcube-build\lib\build\webpack\plugin\issues\index.js:1:1140
at Array.map ()
at i.normalize (C:\snapshot\builder\node_modules@ali\antcube-build\lib\build\webpack\plugin\issues\index.js:1:1112)
at get errors [as errors] (C:\snapshot\builder\node_modules@ali\antcube-build\lib\build\webpack\plugin\issues\index.js:1:965)
at s. (C:\snapshot\builder\node_modules@ali\antcube-build\lib\build\webpack\plugin\lifecycle-notify.js:1:1489)
at Generator.next ()
at C:\snapshot\builder\node_modules\tslib\tslib.js:170:75
at new Promise ()".
at throwUnhandledRejectionsMode (node:internal/process/promises:389:7)
at processPromiseRejections (node:internal/process/promises:470:17)
at process.processTicksAndRejections (node:internal/process/task_queues:96:32) {
code: 'ERR_UNHANDLED_REJECTION'
}

Node.js v20.18.0

Dev server exited unexpectedly with code 1

Please try to restart by clicking 'Restart'

环境信息

👽 Taro v4.0.9


  Taro CLI 4.0.9 environment info:
    System:
      OS: Linux 6.8 Ubuntu 22.04.5 LTS 22.04.5 LTS (Jammy Jellyfish)
      Shell: 5.1.16 - /bin/bash
    Binaries:
      Node: 20.18.0 - ~/.nvm/versions/node/v20.18.0/bin/node
      npm: 10.8.2 - ~/.nvm/versions/node/v20.18.0/bin/npm
    npmPackages:
      @tarojs/cli: 4.0.9 => 4.0.9 
      @tarojs/components: 4.0.9 => 4.0.9 
      @tarojs/helper: 4.0.9 => 4.0.9 
      @tarojs/plugin-framework-vue3: 4.0.9 => 4.0.9 
      @tarojs/plugin-platform-alipay: 4.0.9 => 4.0.9 
      @tarojs/plugin-platform-h5: 4.0.9 => 4.0.9 
      @tarojs/plugin-platform-harmony-hybrid: 4.0.9 => 4.0.9 
      @tarojs/plugin-platform-jd: 4.0.9 => 4.0.9 
      @tarojs/plugin-platform-qq: 4.0.9 => 4.0.9 
      @tarojs/plugin-platform-swan: 4.0.9 => 4.0.9 
      @tarojs/plugin-platform-tt: 4.0.9 => 4.0.9 
      @tarojs/plugin-platform-weapp: 4.0.9 => 4.0.9 
      @tarojs/runtime: 4.0.9 => 4.0.9 
      @tarojs/shared: 4.0.9 => 4.0.9 
      @tarojs/taro: 4.0.9 => 4.0.9 
      @tarojs/taro-loader: 4.0.9 => 4.0.9 
      @tarojs/webpack5-runner: 4.0.9 => 4.0.9 
      babel-preset-taro: 4.0.9 => 4.0.9 
      eslint-config-taro: 4.0.9 => 4.0.9

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions