import { initializeParams } from './helpers/init'; import { VLOverWSHandler } from…
- User
import { initializeParams } from './helpers/init'; import { VLOverWSHandler } from './protocols/vless'; import { TROverWSHandler } from './protocols/trojan'; import { fallback, serveIcon, renderError, renderSecrets, handlePanel, handleSubscriptions, handleLogin, handleError } from './helpers/helpers'; import { logout } from './authentication/auth';
export default { async fetch(request, env) { try { initializeParams(request, env); const upgradeHeader = request.headers.get('Upgrade'); const path = globalThis.pathName; if (!upgradeHeader || upgradeHeader !== 'websocket') { if (path.startsWith('/panel')) return await handlePanel(request, env); if (path.startsWith('/sub')) return await handleSubscriptions(request, env); if (path.startsWith('/login')) return await handleLogin(request, env); if (path.startsWith('/logout')) return await logout(request, env); if (path.startsWith('/error')) return await renderError(); if (path.startsWith('/secrets')) return await renderSecrets(); if (path.startsWith('/favicon.ico')) return await serveIcon(); return await fallback(request); } else { return path.startsWith('/tr') ? await TROverWSHandler(request) : await VLOverWSHandler(request); } } catch (error) { return await handleError(error); } } }
- Assistant
- User
Uncaught Error: No such module "helpers/init". imported from "worker.js"
- Assistant
- User
中文回答
- Assistant
出现错误:
Uncaught Error: No such module "helpers/init". imported from "worker.js"意思是:运行环境找不到你引用的模块
helpers/init。
常见原因及解决方法
1. 路径写错了或者文件不存在
-
你代码中写的是:
import { initializeParams } from './helpers/init';那么你的项目里必须有一个
helpers文件夹,里面必须有个init.js(或init.ts)文件。 -
请确认:
helpers/init.js(或.ts)文件存在
-