手机端启动小程序时,提示 Error: can't find module
发布于 5 年前 作者 klong 8162 次浏览 来自 问答

首先这是我报错的代码:

import {isVoiceRecordUseLatestVersion} from "../../templates/chat-input/chat-input";

当前 Bug 的表现:

在安卓端启动小程序时,提示 “Error: can’t find module : …/…/templates/chat-input/chat-input”

电脑端启动无任何报错,使用真机调式启动也不会有任何报错

错误信息:

预期表现:

不应报错

求解!完全想不到思路,求提供思路!

5 回复

关闭了代码保护,还是有这个错误呀。

只有预览有问题,其他都没问题。

小程序的路径系统绝对有问题!我尝试过很多次了,我把一个组件放在当前目录并require(‘input.js’)就不会报错,我把这个组件放到./input目录下并require(‘input/input.js’)就会报错Module not define!!现在只能通过手动移动文件目录来实现,非常麻烦!!!

我发现可能是 import from 的问题, 将 变成 require 就没问题了,

估计可能是开发工具打包的bug

我也遇到了同样的问题,

import * as chatInput from “…/…/modules/chat-input/chat-input”;

开发者工具调试不报错,ios真机调试也不报错,

但是ios真机使用体验版本(我代码上传成功,确定了无数次),报

thirdScriptError

sdk uncaught third Error

Error

 Error:can’t fined module: …/…/modules/chat-input/chat-input

at(WAService.js:1:1042070)

at(app-service.js:1142:421)

我做的尝试,把 import的变成以下

const chatInput = require("…/…/modules/chat-input/chat-input");

但是依然报错.

thirdScriptError

sdk uncaught third Error

Error

 Error:can’t fined module: …/…/modules/chat-input/chat-input

at(WAService.js:1:1042070)

at(app-service.js:1142:421)

at require(WAService.js:1:1043246)

at(WAService.js:1:1042861)

at(app-service.js:1171:302)

at require(WAService.js:1:1043246)

at global code(app-service.js:1172:17)

这路径检测在工具调试,真机调试,   还有体验版本的真机上不一样么?

官方给个回答,可能的解决方案。  这路径还能怎么改?怎么检查? 工具和真机调试都没问题。 上传代码后的体验版就出问题。

用绝对路径么?

回到顶部