Error: ResourceNotFound.Function, 未找到指定的Function,请创建后再试。
代码片段如下:
const {
AppId: appId,
PrivateKey: privateKey,
} = event.data || {};
const project = new ci.Project({
appid: appId,
type: 'miniProgram',
projectPath: path.resolve(__dirname, 'mini-program-source'),
privateKeyPath: cachePrivateKey(appId, privateKey),
ignores: ['node_modules/**/*'],
});
const uploadFunctionResult = await ci.cloud.uploadFunction({
project,
env: 'cloud02-5g5kbl128b278a3b',
name: 'callback',
path: path.resolve(__dirname, 'mini-program-source/cloudfunctions/callback'),
remoteNpmInstall: true,
onProgressUpdate(arg) {
logger.info(arg);
},
});
云开发控制台中的云函数列表:
具体错误输出如下:
2021-02-08T14:50:19 will upload code under /workspace/mini-program-source/cloudfunctions/callback as cloudfunction 'callback' of env cloud02-5g5kbl128b278a3b. remote-npm-install: true
2021-02-08T14:50:21 checking cloudfunctio status, will only proceed on normal status
2021-02-08T14:50:21 upload cloud02-5g5kbl128b278a3b callback failed: {"code":"ResourceNotFound.Function"}
2021-02-08T14:50:21 name="Evergreen Logger" hostname=a6d2bda6e0e8 pid=2730 request_id=b36443b3-b4c9-4705-93a1-4d9e4f31f67e level=50 msg="Error: ResourceNotFound.Function, 未找到指定的Function,请创建后再试。 (18f0e152-9349-46af-9a3b-6fc59cca9878)" time=2021-02-08T06:50:21.814Z v=0
上传的云函数名称是"callback",实际上你的数据库没有这个云函数存在。