How do I resolve `Missing shims for Node.js built-ins` in an electron rollup app?

Viewed 2451

I'm trying to create a sqlite3 db using knex from inside an electron app built with rollup.

import knex from 'knex';
import 'sqlite3';

const database = knex({
    client: 'sqlite3',
    connection: {
        filename: './games.sqlite'
    },
    useNullAsDefault: true
});

database.schema.hasTable('games').then(exists => {
    if (!exists) {
        return database.schema.createTable('games', t => {
            t.increments('id').primary();
            t.string('name', 100);
        });
    }
});

export default database;

As soon as this code is run I see the following warnings:

(!) Missing shims for Node.js built-ins
Creating a browser bundle that depends on 'util', 'events', 'stream', 'assert', 'timers', 'url', 'path', 'os' and 'buffer'. You might need to include https://github.com/ionic-team/rollup-plugin-node-polyfills
LiveReload enabled
(!) Missing global variable names
Use output.globals to specify browser global variable names corresponding to external modules
util (guessing 'util$6')
events (guessing 'require$$0$1')
stream (guessing 'require$$1')
assert (guessing 'assert')
timers (guessing 'timers_1')
url (guessing 'url')
fs (guessing 'fs')
path (guessing 'path$1')
child_process (guessing 'require$$0$2')
os (guessing 'os')
buffer (guessing 'buffer')

Instaling the suggested rollup-plugin-node-polyfills and adding it in my rollup.config.js plugins list didn't seem to change anything.

0 Answers
Related