JSSoup is not a constructor
Hey! I am trying to use JSSoup in ES6 node.js with modules, but it keeps giving me a JSSoup is not a constructor issue. Any help on this would be appreciated.
make sure you import it correctly
var JSSoup = require('jssoup').default;
user@pop-os:~/vcs/int/jssoup-test$ cat index.js
import JSSoup from 'jssoup';
const html = `
<p>one</p><p>two</p>
<p>three</p>
`;
const soup = new JSSoup(html);
user@pop-os:~/vcs/int/jssoup-test$ node index.js
file:///home/user/vcs/int/jssoup-test/index.js:8
const soup = new JSSoup(html);
^
TypeError: JSSoup is not a constructor
at file:///home/user/vcs/int/jssoup-test/index.js:8:14
at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:409:24)
at async loadESM (node:internal/process/esm_loader:85:5)
at async handleMainPromise (node:internal/modules/run_main:61:12)
Node.js v17.9.0
platform pop!os Linux AMD64
I am also having the same issue. I have tried both import statements listed on the docs, Node JS doesn't like either one.
Anyone have working code with this import??
I am having the same issue as well, even if my fetching function returns a valid response
you need one of the following because the developer exported the name as "default":
ES6+
import JSSoupt from 'jssoup'
const Soup = JSSoup.default
const mysoup = new Soup(<form>)
ES6+
import JSSoup from 'jssoup'
const mysoup = new JSSoup.default(<form>)
ES5
var JSSoup = require('jssoup').default
const mysoup = new JSSoup(<form>)