Closed nikitazdvijkov closed 3 years ago
I get the same error when I attempt to create a new project, as opposed to cloning this repo.
Steps:
npm init -y
npm install node-sword-interface
Copy the example from the README into install_kjv.js
:
const NodeSwordInterface = require('node-sword-interface');
var interface = new NodeSwordInterface();
async function installKJV() {
console.log("Updating repository configuration ...");
await interface.updateRepositoryConfig();
console.log("Installing King James module");
// Install the King James Version (Uses the internet connection to download and install the module)
await interface.installModule('KJV');
}
installKJV().then(() => {
console.log("Installation of KJV successfully completed!");
});
Run via node install_kjv.js
.
Node v16.5.0
NPM v7.21.0
Thank you so much @nikitazdvijkov for reporting this! Something has changed in the API since the example has been created. This will certainly be fixed in the next version.
The first parameter of installModule is the progress callback function. If you adjust the respective call in the example, it should work:
await interface.installModule(undefined, 'KJV');
I can see how the new API is a bit inconvenient. I had a reason to change the API end of last year, but I can check whether this is still valid as of today.
That fixed it, thanks!
I fixed the API with 764237d1998734e53aea4ea7740d37e805c6911b and version 0.236.0 (published on npmjs). The examples are now working again without any changes.
Hi I'm trying to run this same example. I've used npm to install the module. The unmodified example gives me:
Updating repository configuration ... Installing King James module node:internal/process/promises:246 triggerUncaughtException(err, true / fromPromise /); ^
[UnhandledPromiseRejection: This error originated either by throwing inside of an async function wit hout a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejec ted with the reason "-9".] { code: 'ERR_UNHANDLED_REJECTION' }
Using
await interface.installModule(undefined, 'KJV');
gives me:
Updating repository configuration ... Installing King James module node_modules/node-sword-interface/index.js:240 this.nativeInterface.installModule(moduleCode, progressCB, function(result) { ^
TypeError: String expected for argument 1 at node_modules/node-sword-interface/index.js:240:2 8 at new Promise (
) at NodeSwordInterface.installModule (node_modules/n ode-sword-interface/index.js:239:12) at installKJV (install_kjv.js:13:19)
Cloning master works tho!
Node v16.11.0 Npm v7.24.1
Thanks for checking this once more. Maybe something went wrong when publishing the package. I am going to re-open this issue and re-publish the package with a new version.
Mmmm... @kthenrique Which exact example code did you use?
If I install the latest version 0.236.0 via npm I can run the included example without any issues like this (first cd into the directory of node-sword-interface):
node examples/install_kjv.js
The adjustment above is no longer necessary, which means that await interface.installModule('KJV');
as shown in the latest README should work.
Oh this is odd! Now it works... I've no clue what is different now! sorry for the inconvenience.
Steps:
npm install
the repo.node examples/install_kjv.js
.Result: