我也遇到了 解决了嘛 楼主
云函数引入got报错云函数代码: // 云函数入口文件 const cloud = require('wx-server-sdk') const got = require('got') cloud.init() // 云函数入口函数 exports.main = async (event, context) => { const wxContext = cloud.getWXContext() return { event, openid: wxContext.OPENID, appid: wxContext.APPID, unionid: wxContext.UNIONID, } } package.json { "name": "http", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", "license": "ISC", "dependencies": { "got": "^12.0.1", "wx-server-sdk": "^2.5.3" } } 报错信息: Error: errCode: -404011 cloud function execution error | errMsg: cloud.callFunction:fail requestID 84e73b60-fce3-49b8-ae13-b74247eaa248, cloud function service error code -504002, error message Runtime. ImportModuleError: Error: Cannot find module 'got'Require stack: - /var/user/index.js - /var/runtime/node12/UserFunction.js - /var/runtime/node12/Runtime.engine.js - /var/runtime/node12/bootstrap.js at Object.module.exports.load (:20392/var/runtime/node12/UserFunction.js:34) at Runtime.handleOnce (:20392/var/runtime/node12/Runtime.engine.js:99) at Timeout._onTimeout (:20392/var/runtime/node12/Runtime.engine.js:56) at listOnTimeout (:20392/appservice/internal/timers.js:549) at processTimers (:20392/appservice/internal/timers.js:492); at cloud.callFunction api; at new e (VM54 WAService.js:26) at s (VM54 WAService.js:26) at c (VM54 WAService.js:26) at Function.success (VM54 WAService.js:26) at I (VM54 WAService.js:2) at VM54 WAService.js:2 at u (VM54 WAService.js:35) at Function.<anonymous> (VM54 WAService.js:35) at I (VM54 WAService.js:2) at VM54 WAService.js:2(env: Windows,mp,1.05.2110290; lib: 2.14.1)
2022-04-23