gpt4 book ai didi

node.js - 如何修复错误 : SQLITE_CANTOPEN: unable to open database on Zeit. co?

转载 作者:行者123 更新时间:2023-12-03 20:57:28 28 4
gpt4 key购买 nike

我想连接到我的数据库 sqlite3。这在本地主机上运行良好,但在我部署到 zeit.co 时失败,出现错误:

Error: SQLITE_CANTOPEN: unable to open database

据我了解,这个问题是因为我们无法获得数据库文件的正确路径。我尝试了一些解决方案,但仍然失败。请帮忙!!!

这是 zeit.co 日志上的错误:

2020-02-13T07:50:40.031Z 4d5a9aed-ae26-4a09-903a-72aa08ca5140 ERROR Unhandled Promise Rejection {"errorType":"Runtime.UnhandledPromiseRejection","errorMessage":"Error: SQLITE_CANTOPEN: unable to open database file","reason":{"errorType":"Error","errorMessage":"SQLITE_CANTOPEN: unable to open database file","code":"SQLITE_CANTOPEN","errno":14,"stack":["Error: SQLITE_CANTOPEN: unable to open database file"]},"promise":{"isFulfilled":false,"isRejected":true,"rejectionReason":{"errorType":"Error","errorMessage":"SQLITE_CANTOPEN: unable to open database file","code":"SQLITE_CANTOPEN","errno":14,"stack":["Error: SQLITE_CANTOPEN: unable to open database file"]}},"stack":["Runtime.UnhandledPromiseRejection: Error: SQLITE_CANTOPEN: unable to open database file"," at process. (/var/runtime/index.js:35:15)"," at process.emit (events.js:228:7)"," at eventToObjectGenerator.promiseCreated (/var/task/node_modules/bluebird/js/release/debuggability.js:258:33)"," at activeFireEvent (/var/task/node_modules/bluebird/js/release/debuggability.js:301:44)"," at fireRejectionEvent (/var/task/node_modules/bluebird/js/release/debuggability.js:703:14)"," at Promise._notifyUnhandledRejection (/var/task/node_modules/bluebird/js/release/debuggability.js:90:9)"," at Timeout.unhandledRejectionCheck [as _onTimeout] (/var/task/node_modules/bluebird/js/release/debuggability.js:39:25)"," at listOnTimeout (internal/timers.js:531:17)"," at processTimers (internal/timers.js:475:7)"]} Unknown application error occurred



这是我连接到sqlite的代码
const fs = require('fs');
const path = require('path');

const DBSOURCE = path.join(__dirname, 'mydb.sqlite');

const knex = require('knex')({
client: 'sqlite3',
connection: {
filename: DBSOURCE
}
});

笔记:
  • 我试过 const DBSOURCE = 'mydb.sqlite' ;
  • 我试过 const DBSOURCE = path.resolve(__dirname, 'mydb.sqlite');
  • 最佳答案

    对于那些从谷歌这里绊倒的人,Zeit 现在是 Vercel,并且有一个在无服务器环境中使用 MySQL 的更新示例。
    https://github.com/vercel/next.js/tree/canary/examples/with-mysql

    关于node.js - 如何修复错误 : SQLITE_CANTOPEN: unable to open database on Zeit. co?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60202995/

    28 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com