diff --git a/.cursor/skills/kbone-miniprogram/troubleshooting.md b/.cursor/skills/kbone-miniprogram/troubleshooting.md index 2ddc01b6..62426756 100644 --- a/.cursor/skills/kbone-miniprogram/troubleshooting.md +++ b/.cursor/skills/kbone-miniprogram/troubleshooting.md @@ -199,6 +199,31 @@ resolve: { ## 运行时问题 +### 0. TypeError: eval is not a function + +**错误信息**: +``` +TypeError: eval is not a function + at Object../src/index.jsx (index.js?...) +``` + +**原因**:`npm run mp` 使用 development 模式时,webpack 默认 `devtool: 'eval'`,会注入使用 `eval()` 的代码;小程序环境**不支持** `eval`,因此报错。 + +**解决方案**:在 **webpack.mp.config.js** 中显式关闭 devtool: + +```javascript +module.exports = { + mode: process.env.NODE_ENV === 'production' ? 'production' : 'development', + devtool: false, // 小程序环境不支持 eval,必须关闭 + entry: { ... }, + // ... +} +``` + +重新执行 `npm run mp` 或 `npm run build:mp` 后,再在微信开发者工具中预览即可。 + +--- + ### 1. URLSearchParams 未定义 **错误信息**: diff --git a/newapp b/newapp deleted file mode 160000 index 5f9ae76b..00000000 --- a/newapp +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 5f9ae76b400232f5b5c9b8cdb2fe21e0dab9cafa diff --git a/next-env.d.ts b/next-env.d.ts index 9edff1c7..c4b7818f 100644 --- a/next-env.d.ts +++ b/next-env.d.ts @@ -1,6 +1,6 @@ /// /// -import "./.next/types/routes.d.ts"; +import "./.next/dev/types/routes.d.ts"; // NOTE: This file should not be edited // see https://nextjs.org/docs/app/api-reference/config/typescript for more information.