
大家好
我正在尝试建立与不使用 sql 连接的数据库模式的连接。我使用 node js 作为后端,在运行该项目时,出现以下错误;
`ps c:usersgcobanicoding-challengebackend> 纱线开发
纱线运行 v1.22.22
警告..package.json:没有许可证字段
$ tsx watch src/index.ts
节点:内部/进程/承诺:288
triggeruncaughtexception(err, true /* frompromise */);
^
[错误:sqlite_cantopen:无法打开数据库文件] {
错误号:14,
代码:'sqlite_cantopen'
}
node.js v18.20.4`
解决问题如下:只列举最近用户提交问题,其余问题前面几次补丁已经解决,不在复述。1、解决搜索问题。以前搜索一定要确定到省下面的某个市,这个不符合用户体验。 现在改为,省--所有城市(默认为所有城市,也可以自己选择某个市)。2、解决首页推荐产品部显示问题。(以前没有考虑多个其他浏览器)3、解决供应、求购 今日产品显示问题。(理由同上)4、解决收藏商家、供应、求购问题。 (链接错误)5、解决后台分类过
// 这是我在 vs code 项目上的打字稿和文件路径
从 'sequelize' 导入 { sequelize };
从“路径”导入路径;
// dbpath 应反映 winedrops.db 文件的位置
const dbPath = path.resolve(__dirname, 'db/winedrops.db'); // This should work if __dirname points to 'src'
console.log('Database path:', dbPath); // Log the path to confirm
export const sequelize = new Sequelize({
dialect: 'sqlite',
storage: dbPath,
});
async function testConnection() {
try {
await sequelize.authenticate();
console.log('Connection has been established successfully.');
} catch (error) {
console.error('Unable to connect to the database:', error.message);
}
}
testConnection();









