try {
await uniCloud.httpclient.request(
'https://api.weixin.qq.com/sns/jscode2session', {
method: 'GET',
data: {
appid: 'xx',
secret:'xx',
js_code:'xx',
grant_type: 'authorization_code'
},
contentType: 'json',
dataType: 'json'
});
} catch (e) {
//TODO handle the exception
console.log('wx', e);
}
- 发布:2023-09-24 13:38
- 更新:2023-09-24 13:38
- 阅读:1066
产品分类: uniCloud/腾讯云
示例代码:
操作步骤:
用require接入该代码后引用,上传云函数到云端,然后发布小程序正式版
用require接入该代码后引用,上传云函数到云端,然后发布小程序正式版
预期结果:
本地运行和云端运行一致
本地运行和云端运行一致
实际结果:
本地没有报错,云端报错如下
Error: [functionName]: Error: Cannot find module 'address'
Require stack:
- /var/user/node_modules/digest-header/node_modules/utility/lib/utility.js
- /var/user/node_modules/digest-header/node_modules/utility/index.js
- /var/user/node_modules/digest-header/index.js
- /var/user/node_modules/urllib/lib/urllib.js
- /var/user/node_modules/urllib/lib/index.js
- /var/user/@dcloudio/serverless/lib/tcb/uni-cloud.js
- /var/user/index.js
- /var/runtime/node12/UserFunction.js
- /var/runtime/node12/Runtime.engine.js
- /var/runtime/node12/bootstrap.js
at Function.Module._resolveFilename (:45335/appservice/internal/modules/cjs/loader.js:982)
at Function.Module._load (:45335/appservice/internal/modules/cjs/loader.js:864)
at Module.require (:45335/appservice/internal/modules/cjs/loader.js:1044)
at require (:45335/appservice/internal/modules/cjs/helpers.js:77)
at Object.<anonymous> (:45335/var/user/node_modules/digest-header/node_modules/utility/lib/utility.js:15)
at Module._compile (:45335/appservice/internal/modules/cjs/loader.js:1158)
at Object.Module._extensions..js (:45335/appservice/internal/modules/cjs/loader.js:1178)
at Module.load (:45335/appservice/internal/modules/cjs/loader.js:1002)
at Function.Module._load (:45335/appservice/internal/modules/cjs/loader.js:901)
at Module.require (:45335/appservice/internal/modules/cjs/loader.js:1044)
at new Ca (vendor.js? [sm]:1)
at Pc.send (vendor.js? [sm]:1)(env: Windows,mp,1.06.2308310; lib: 2.30.4)
本地没有报错,云端报错如下
Error: [functionName]: Error: Cannot find module 'address'
Require stack:
- /var/user/node_modules/digest-header/node_modules/utility/lib/utility.js
- /var/user/node_modules/digest-header/node_modules/utility/index.js
- /var/user/node_modules/digest-header/index.js
- /var/user/node_modules/urllib/lib/urllib.js
- /var/user/node_modules/urllib/lib/index.js
- /var/user/@dcloudio/serverless/lib/tcb/uni-cloud.js
- /var/user/index.js
- /var/runtime/node12/UserFunction.js
- /var/runtime/node12/Runtime.engine.js
- /var/runtime/node12/bootstrap.js
at Function.Module._resolveFilename (:45335/appservice/internal/modules/cjs/loader.js:982)
at Function.Module._load (:45335/appservice/internal/modules/cjs/loader.js:864)
at Module.require (:45335/appservice/internal/modules/cjs/loader.js:1044)
at require (:45335/appservice/internal/modules/cjs/helpers.js:77)
at Object.<anonymous> (:45335/var/user/node_modules/digest-header/node_modules/utility/lib/utility.js:15)
at Module._compile (:45335/appservice/internal/modules/cjs/loader.js:1158)
at Object.Module._extensions..js (:45335/appservice/internal/modules/cjs/loader.js:1178)
at Module.load (:45335/appservice/internal/modules/cjs/loader.js:1002)
at Function.Module._load (:45335/appservice/internal/modules/cjs/loader.js:901)
at Module.require (:45335/appservice/internal/modules/cjs/loader.js:1044)
at new Ca (vendor.js? [sm]:1)
at Pc.send (vendor.js? [sm]:1)(env: Windows,mp,1.06.2308310; lib: 2.30.4)
bug描述:
uniCloud.httpclient.request函数在正式版出现依赖异常
发布新的正式版时,在获取openid时报依赖错误,我都没改这段代码,突然就出错了。
补充:我把旧版本的云函数改名字重新上传,也会出现这个报错。
补充:我的代码没有依赖address、也没有依赖digest-header
Error: [functionName]: Error: Cannot find module 'address'
Require stack:
- /var/user/node_modules/digest-header/node_modules/utility/lib/utility.js
- /var/user/node_modules/digest-header/node_modules/utility/index.js
- /var/user/node_modules/digest-header/index.js
- /var/user/node_modules/urllib/lib/urllib.js
- /var/user/node_modules/urllib/lib/index.js
- /var/user/@dcloudio/serverless/lib/tcb/uni-cloud.js
- /var/user/index.js
- /var/runtime/node12/UserFunction.js
- /var/runtime/node12/Runtime.engine.js
- /var/runtime/node12/bootstrap.js
at Function.Module._resolveFilename (:45335/appservice/internal/modules/cjs/loader.js:982)
at Function.Module._load (:45335/appservice/internal/modules/cjs/loader.js:864)
at Module.require (:45335/appservice/internal/modules/cjs/loader.js:1044)
at require (:45335/appservice/internal/modules/cjs/helpers.js:77)
at Object.<anonymous> (:45335/var/user/node_modules/digest-header/node_modules/utility/lib/utility.js:15)
at Module._compile (:45335/appservice/internal/modules/cjs/loader.js:1158)
at Object.Module._extensions..js (:45335/appservice/internal/modules/cjs/loader.js:1178)
at Module.load (:45335/appservice/internal/modules/cjs/loader.js:1002)
at Function.Module._load (:45335/appservice/internal/modules/cjs/loader.js:901)
at Module.require (:45335/appservice/internal/modules/cjs/loader.js:1044)
at new Ca (vendor.js? [sm]:1)
at Pc.send (vendor.js? [sm]:1)(env: Windows,mp,1.06.2308310; lib: 2.30.4)
0 个回复