簡體   English   中英

從nodejs腳本使用時,knex.js不返回

[英]knex.js not returning when using from nodejs script

我在nodejs腳本中將knex.js用作ORM,但是當我從命令行運行它時,腳本“凍結”,並且沒有像以前那樣在添加knex之前結束:

~/dir $ node index.js projects read-all
freeze
adadazdzadad



^C
~/dir $

因此,我別無選擇,只能每次使用Ctrl+C退出腳本,並且我想避免這種情況並以干凈的方式結束腳本。 但是如何?

index.js

var args = require('yargs').argv;
var knex = require('knex')({
  client: 'sqlite3',
  connection: {
    filename: './data.db'
  }
});

console.log(args);

添加knex.destroy(); 在腳本末尾解決了問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM