Errors on initial import
SeanBannister opened this issue · comments
Created a blank project using Node v12.17.0 which now has ESM module support ready for primetime (no longer requires a flag) so I'm not using babel (which might be the problem?).
Getting the error:
import { QAClient } from 'question-answering';
^^^^^^^^
SyntaxError: The requested module 'question-answering' does not provide an export named 'QAClient'
Tried to do a quick debug and everything seems fine but as soon as I saw the typescript file I freaked out 😉 don't really have an expereince with it so unsure if this is the issue. Would be awesome if the package worked with vanilla Node ESM module imports though.
So I switched to commonjs const { QAClient } = require("question-answering");
and now I'm getting the error:
internal/modules/cjs/loader.js:1188
return process.dlopen(module, path.toNamespacedPath(filename));
^
Error: The specified module could not be found.
\\?\L:\Training datasets\New folder\node_modules\@tensorflow\tfjs-node\lib\napi-v5\tfjs_binding.node
at Object.Module._extensions..node (internal/modules/cjs/loader.js:1188:18)
at Module.load (internal/modules/cjs/loader.js:986:32)
at Function.Module._load (internal/modules/cjs/loader.js:879:14)
at Module.require (internal/modules/cjs/loader.js:1026:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (L:\Training datasets\New folder\node_modules\@tensorflow\tfjs-node\dist\index.js:58:16)
at Module._compile (internal/modules/cjs/loader.js:1138:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
at Module.load (internal/modules/cjs/loader.js:986:32)
at Function.Module._load (internal/modules/cjs/loader.js:879:14)
Even without any code and just the require.
There's mention of this in #7 but no conclusion.
And I have run npx question-answering download
.
Also tried 2.x and 3.x versions.
It seems your problem is related to the underlying TensorFlow library. Can you try running npm i @tensorflow/tfjs-node
in your project to be sure it's correctly installed and try again?
@Pierrci thanks for the help. Unfortunately no luck still receiving the same errors. I'm using the bare minimum trying to test this out, here's an example git repo with the code.
Example expects you to run:
npm install question-answering@latest
and
npx question-answering download
I fired up a Ubuntu virtual machine and found it works find under Ubuntu, however I'm not having any luck under Windows 10. Wondering if anyone else can test to see if this is just my Windows machine or if it's a larger issue.
Mmmm it might be a tfjs/windows related issue then...
Can you try to setup a new empty node project, install tfjs-node directly inside it (no question-answering
package) with npm i @tensorflow/tfjs-node
, then do a simple const tf = require('@tensorflow/tfjs-node');
in an index.js
file, run it with node and see if you get the same error?
Thanks for your help with this. I tested just tfjs-node and it runs fine. To do some further testing I put together a quick demo that utilized tfjs-node to do some basic training, still no errors.
So I fired up another Windows 10 machine to see if it was specific to the machine I was using. Pretty much installed everything from scratch, node, windows build tools, etc, and received exactly the same error. Interested to hear if anyone else here is using Windows 10.
Ok I think I got it, it's probably related to the Node version you're using: v12.17+ ship with N-API 6, and only tfjs-node 2+ is compatible with that. I updated the dependencies on the v3 a few days ago so it should work now, can you try again in your project by doing a npm i question-answering@next
to be sure to get the last RC of v3?
Actually I just published the final version of the v3, so you can just do npm i question-answering@latest
:)
Brilliant, that appears to be the issue, running as expected now :) thanks again for your help with this. Looking forward to playing around with it.