我正在 Svelte Sapper 中创建一个应用程序。我有一个routes/account/login.js
API 路由,我正在尝试使用mysql2。路由本身有效(我检查了 Postman),但是一旦我导入 mysql,服务器就会崩溃并出现错误:
[rollup-plugin-svelte] The following packages did not export their `package.json` file so we could not check the "svelte" field. If you had difficulties importing svelte components from a package, then please contact the author and ask them to export the package.json file.
- mysql2
import mysql from "mysql2/promise";
export async function post(req, res) {
//route test
const { login, password } = req.body;
res.end(`${login}, ${password}`);
}
我该怎么做才能使这个导入工作?我该怎么做才能使这个导入工作?
Sapper 文档没有说明您是否需要另外更改配置中的某些内容。https://sapper.svelte.dev/docs#Server_routes