错误信息:
Error: cloud.callFunction:fail -404011 cloud function execution error. 云函数执行错误
云端堆栈信息(error stack)(requestId 11024889-de09-11eb-a0a6-52540096f86f, callid 1625541608169-0.6493597940355504):
Error: EACCES: permission denied, open '/var/user/index.js'
at Object.openSync (:61480/appservice/fs.js:438)
at Object.readFileSync (:61480/appservice/fs.js:343)
at Object.Module._extensions..js (:61480/appservice/internal/modules/cjs/loader.js:711)
at Module.load (:61480/appservice/internal/modules/cjs/loader.js:600)
at tryModuleLoad (:61480/appservice/internal/modules/cjs/loader.js:539)
at Function.Module._load (:61480/appservice/internal/modules/cjs/loader.js:531)
at Module.require (:61480/appservice/internal/modules/cjs/loader.js:637)
at require (:61480/appservice/internal/modules/cjs/helpers.js:22)
at Object.module.exports.load (:61480/var/runtime/node10/UserFunction.js:27)
at Runtime.handleOnce (:61480/var/runtime/node10/Runtime.engine.js:97)(env: macOS,mp,1.05.2106300; lib: 2.17.0)
云函数代码:
// 云函数入口文件
const cloud = require('wx-server-sdk')
cloud.init()
// 云函数入口函数
exports.main = async (event, context) => {
const wxContext = cloud.getWXContext()
return {
event,
openid: wxContext.OPENID,
appid: wxContext.APPID,
unionid: wxContext.UNIONID,
}
}
云函数上传成功、部署成功,而且云函数和云开发环境的权限全都已经放开,允许所有用户访问。请问为什么还是会出现Permission denied错误呢?
你好,尝试增量上传下该云函数内的 index.js 文件?看起来是文件上传异常导致权限问题。
---
经排查,用户的云函数目录存在异常权限,建议先通过如下命令重置权限符。