【发布时间】:2021-11-14 08:00:32
【问题描述】:
我正在 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
【问题讨论】:
标签: node.js svelte rollup sapper node-mysql2