-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Failed to install cordova-sqlite-ext" cordova 9.0.0 #44
Comments
@HarelM have you had this issue? |
I was unable to make Cordova 9.0 fully work on my machine (Win 10). I'm still using 8 due to that fact... |
Which version of Cordova 8 are you running? I tried installing some
versions of 8 and had the same problem.
|
go to \plugins\cordova-sqlite-ext\scripts\beforePluginInstall.js add --> var Q = require('q'); |
Thanks for the tip! |
@mb72 I have now switch to latest - 9.0. I think the problem in my case of migrating to Cordova 9.0 was that I used |
@HarelM Thanks, but I'm not seeing how your project integrates with Cordova. What are the steps for turning it into an app? Where do the mbtiles files go? |
@mb72 there are several "moving parts" involved here, I'll see if I can better explain then: var sqlite3 = require('sqlite3').verbose();
var fs = require('fs');
var pako = require('pako');
var main = require('async-main').default;
let dbFilePath = process.argv[2];
let filePrefix = process.argv[3];
let recordsSplit = process.argv[4];
console.log(`Database file name: ${dbFilePath}`);
console.log(`Output file name prefix: ${filePrefix}`);
console.log(`Maximal number of record in each file: ${recordsSplit}`);
main(async () => {
var sqlDb = new sqlite3.Database(dbFilePath, sqlite3.OPEN_READONLY);
var data = await new Promise((resolve, reject) => {
var res = []
sqlDb.all('SELECT * FROM tiles', (err, rows) => {
for (let row of rows) {
var y = Math.pow(2, row.zoom_level) - row.tile_row - 1;
var id = `${row.zoom_level}_${row.tile_column}_${y}`;
var rawData = row.tile_data;
let isGzipped = rawData[0] === 0x1f && rawData[1] === 0x8b;
if (isGzipped) {
rawData = new Buffer(pako.inflate(rawData).buffer);
}
console.log(id);
res.push({id: id, x: row.tile_column, y: y, z: row.zoom_level, data: rawData.toString("base64")});
}
resolve(res);
});
});
let fileNameIndex = 0;
let promisesArray = [];
while (data.length > 0) {
let dataToDump = data.splice(0, recordsSplit);
let fileNameIndexString = fileNameIndex.toString();
let fileName = filePrefix + fileNameIndexString.padStart(10, '0') + ".json";
fileNameIndex++;
let promise = new Promise((resolve, reject) => {
fs.writeFile(fileName, JSON.stringify(dataToDump), (err) => {
if (err) {
reject(err);
}
console.log(`Finished writing: ${fileName}`);
resolve();
})
});
promisesArray.push(promise);
}
await Promise.all(promisesArray);
}); After I have this file containing json data I can load it the browser database as a document and fetch it with the custom hook. |
I had the original issue here, too, and followed these suggestions to fix it:
|
I get an error when adding Cordova platforms - "Failed to install 'cordova-sqlite-ext': CordovaError: Using "requireCordovaModule" to load non-cordova module "q" is not supported. Instead, add this module to your dependencies and use regular "require" to load it."
The text was updated successfully, but these errors were encountered: