Skip to content

Issues serving Edge Functions locally

如果 supabase functions serve 失败或者你在本地运行 Edge Functions 遇到问题,按照这些步骤来排查和解决问题。

🌐 If supabase functions serve fails or you're having trouble running Edge Functions locally, follow these steps to diagnose and resolve the issue.

调试步骤 #

🌐 Debugging steps

使用调试模式 #

🌐 Use debug mode

使用 --debug 标志运行 serve 命令以获取详细输出:

🌐 Run the serve command with the --debug flag for detailed output:

1
supabase functions serve your-function --debug

检查端口可用性 #

🌐 Check port availability

确保所需的端口可用。Supabase CLI 默认使用端口 543218081

🌐 Ensure the required ports are available. The Supabase CLI uses ports 54321 and 8081 by default:

1
# Check if port 54321 is in use
2
lsof -i :54321
3
4
# Check if port 8081 is in use
5
lsof -i :8081

如果这些端口正在使用,停止使用它们的进程或者配置其他端口。

🌐 If these ports are in use, stop the processes using them or configure different ports.

常见问题 #

🌐 Common issues

端口冲突 #

🌐 Port conflicts

可能有其他进程正在使用所需的端口。检查一下:

🌐 Another process may be using the required ports. Check for:

  • 本地运行的其他 Supabase 项目
  • Docker 容器
  • 其他开发服务器

Deno 缓存问题 #

🌐 Deno cache issues

如果你遇到模块解析问题,可以清理 Deno 缓存:

🌐 Clear the Deno cache if you're experiencing module resolution problems:

1
deno cache --reload /path/to/function/index.ts

环境变量 #

🌐 Environment variables

确保你的 .env 文件已正确配置并且可以被命令行访问。

🌐 Make sure your .env file is properly configured and accessible to the CLI.

获得更多帮助 #

🌐 Getting more help

如果问题仍然存在,可以在以下仓库中搜索类似的错误信息:

🌐 If the problem persists, search the following repositories for similar error messages:

如果这些命令的输出不能解决问题,可以通过 Supabase 仪表板(点击右上角的“帮助”按钮)提交支持请求,并附上所有输出和命令的详细信息。

🌐 If the output from these commands does not help resolve the issue, open a support ticket via the Supabase Dashboard (by clicking the "Help" button at the top right) and include all output and details about your commands.

额外资源 #

🌐 Additional resources