Persistent API Cumulative Projects - STEP 17


I´m trying to create a Table and add to my database.sqlite. The problem is that it doesn´t log to the database.

const sqlite3 = require(‘sqlite3’);

const db = new sqlite3.Database(’./database.sqlite’);

db.serialize(function(){'CREATE TABLE IF NOT EXISTS `Artist` ( ' +


'`name` TEXT NOT NULL, ' +

'`date_of_birth` TEXT NOT NULL, ' +

'`biography` TEXT NOT NULL, ' +

'`is_currently_employed` INTEGER NOT NULL DEFAULT 1, ' +

'PRIMARY KEY(`id`) )');


Thank you so much

From the error message it looks like the file migration.js is not present in the directory where you do “node migration.js” from.

When you first ran npm install, did you notice any strange errors? When I worked on this project, I found that the newer versions of node weren’t compatible with the older version of sqlite3 that was being referenced in the project’s package.json file.

The solutions were to either downgrade to an older version of node, install a node version manager and switch to an older version, or to use a newer version of sqlite3 for the project.

I used the last option because of this post: Problem installing sqlite3

This worked perfectly for me after making the change in package.json and running npm install. Nothing else in the project needed to be adjusted to complete.

1 Like

I´ve already done and everything is installed correctly. The problem is that my package.json doesn´t upload when I install all my npm .

Any idea?

The error message looks like what you will get if you try to open a file that does not exist with node. Try typing “node no_file.js” for example when there is no such file. You will see a very similar msg. Double-check that you put code in migration.js and that you are in that same directory when running “node migration.js”.

I´ve already solved. I re-installed node and instal sql again.

Thank you