Create new table using better-sqlite3


I am trying to create a new table using node.js and better-sqlite3. When I execute the file, it returns the following error:

ReferenceError: createtable is not defined at Object.<anonymous> ( file's path...)

How can I solve it?
Here’s my code:

const express = require('express');
var createError = require('http-errors');
const app = express();
const port = 3000;
const sqlitedb = require('better-sqlite3');

const createTable = "CREATE TABLE IF NOT EXISTS users('name' varchar, 'surname' varchar, 'date_of_birth' DATE DEFAULT, 'email' varchar, 'username' varchar PRIMARY KEY, 'password' varchar );"

const dbusers = './databaseUsers.sqlite3';
let db = new sqlitedb(dbusers , sqlitedb.OPEN_READWRITE, (err) => {
    if (err) {
    verbose: console.log}


Thank you in advance 😉


You have a typo in the variable declaration. The variable you declared is createTable instead of createtable (note the capitalized T). So it should be:


Answered By – Danny

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published