打开编译后的小程序代码提示错误
相关平台
字节跳动小程序
小程序基础库: 3.11.0 使用框架: Vue 3
复现步骤
1、npm run dev:tt 2、抖音开发工具加载编译后的小程序代码
3、提示错误: [TMA] {message: "Can't find module ./prebundle/vendors-node_modules…undle_nutui_nutui-taro_js.ttss imported by app.js", name: "USER_GLOBAL_ERROR", stack: "at ?(USER_RESOLVE_MODULE_ERROR: Can't find module …://127.0.0.1:7045/app-dist/app-service.js:139:2)↵"}
期望结果
头条小程序开发工具加载编译代码目录不出现异常错误。
实际结果
小程序开发工具编译代码异常
环境信息
Taro CLI 3.6.19 environment info:
System:
OS: macOS 12.7.2
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 20.11.0 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 10.2.4 - /usr/local/bin/npm
npmPackages:
@tarojs/cli: 3.6.19 => 3.6.19
@tarojs/components: 3.6.19 => 3.6.19
@tarojs/helper: 3.6.19 => 3.6.19
@tarojs/plugin-framework-vue3: 3.6.19 => 3.6.19
@tarojs/plugin-html: ^3.6.23 => 3.6.23
@tarojs/plugin-platform-alipay: 3.6.19 => 3.6.19
@tarojs/plugin-platform-h5: 3.6.19 => 3.6.19
@tarojs/plugin-platform-jd: 3.6.19 => 3.6.19
@tarojs/plugin-platform-qq: 3.6.19 => 3.6.19
@tarojs/plugin-platform-swan: 3.6.19 => 3.6.19
@tarojs/plugin-platform-tt: 3.6.19 => 3.6.19
@tarojs/plugin-platform-weapp: 3.6.19 => 3.6.19
@tarojs/plugin-vue-devtools: ^3.6.21 => 3.6.21
@tarojs/runtime: 3.6.19 => 3.6.19
@tarojs/shared: 3.6.19 => 3.6.19
@tarojs/taro: 3.6.19 => 3.6.19
@tarojs/taro-loader: 3.6.19 => 3.6.19
@tarojs/webpack5-runner: 3.6.19 => 3.6.19
babel-preset-taro: 3.6.19 => 3.6.19
eslint-config-taro: 3.6.19 => 3.6.19
错误信息
npm run dev:tt 过程正常,没有错误
app.js
import {createApp} from 'vue'
import './app.scss'
import {login} from './utils/api'
import Taro from '@tarojs/taro';
const App = createApp({
onShow(options) {
console.log('App onShow.')
},
onLaunch(e) {
console.log(e);
login().then(res=> res);
}
// 入口组件不需要实现 render 方法,即使实现了也会被 taro 所覆盖
})
export default App
prebundle 配置 exclude 掉 nutui 试试,或者直接关闭 prebundle
@Chen-jj dev prebundle默认开启的,设置false 后小程序编译加载代码正常了。然后又还原prebundle:true, 小程序编译加载也正常了 反复试几次 错误又出来了。不稳定
@Chen-jj dev prebundle默认开启的,设置false 后小程序编译加载代码正常了。然后又还原prebundle:true, 小程序编译加载也正常了 反复试几次 错误又出来了。不稳定
参考:https://github.com/jdf2e/nutui/issues/2461#issuecomment-1655316373
关闭 prebundle 或者将第三方组件库排除在外,是必要的配置。