运行环境:node20, nextjs15 react18
代码只写了登录功能,打包的时候出现缺少 bufferutil 和 utf-8-validate 两个依赖,然后报错
const handleLogin = () => {
setLoading(true)
User.logIn(username, password).then(
(user) => {
// 登录成功
messageApi.success("欢迎回来," + user.getUsername())
setVisible(false)
props.onLogin()
},
(error) => {
// 登录失败
messageApi.error(error.message)
}
).finally(() => {
setLoading(false)
})
}
错误:
node_modules/.pnpm/formidable@2.1.2/node_modules/formidable/src/Formidable.js (15:1) @ eval
⨯ TypeError: hexoid is not a function
at webpack_require (/workspace/homepage/dist/server/webpack-runtime.js:33:43)
at webpack_require (/workspace/homepage/dist/server/webpack-runtime.js:33:43)
at webpack_require (/workspace/homepage/dist/server/webpack-runtime.js:33:43)
at webpack_require (/workspace/homepage/dist/server/webpack-runtime.js:33:43)
at webpack_require (/workspace/homepage/dist/server/webpack-runtime.js:33:43)
at webpack_require (/workspace/homepage/dist/server/webpack-runtime.js:33:43)
at webpack_require (/workspace/homepage/dist/server/webpack-runtime.js:33:43)
at eval (./src/hooks/leancloud.ts:5:75)
at (ssr)/./src/hooks/leancloud.ts (/workspace/homepage/dist/server/app/moment/page.js:463:1)
at webpack_require (/workspace/homepage/dist/server/webpack-runtime.js:33:43)
at eval (./src/app/moment/page.tsx:9:78)
at (ssr)/./src/app/moment/page.tsx (/workspace/homepage/dist/server/app/moment/page.js:419:1)
at Object.webpack_require as require
at JSON.parse ()
digest: "3492828021"
13 | const qs = require('qs');
14 |
15 | const toHexoId = hexoid(25);
| ^
16 | const DEFAULT_OPTIONS = {
17 | maxFields: 1000,
18 | maxFieldsSize: 20 * 1024 * 1024,
GET /moment 500 in 63ms