Files
heros/build-templates/wechatgame/cloud_functions/cocos_cloud/deploy.md
2025-10-19 20:10:19 +08:00

32 lines
827 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 云函数部署指南
## 问题描述
```
Error: cloud.callFunction:fail Error: errCode: -504002 functions execute fail | errMsg: Error: Cannot find module 'wx-server-sdk'
```
## 解决方案
### 1. 安装依赖
在云函数目录下执行:
```bash
npm install
```
### 2. 验证依赖安装
检查 `node_modules` 目录是否存在且包含 `wx-server-sdk`
```bash
ls node_modules/wx-server-sdk
```
### 3. 重新部署云函数
使用微信开发者工具重新上传并部署云函数。
### 4. 检查云开发环境
确保云开发环境已正确初始化,并且云函数配置正确。
## 注意事项
1. 确保网络连接正常,能够访问 npm 源
2. 如果使用了代理,需要正确配置 npm 代理
3. 确保云开发环境 ID 配置正确
4. 检查云函数名称是否与代码中调用的一致