taoqf / node-html-parser

A very fast HTML parser, generating a simplified DOM, with basic element query support.
MIT License
1.12k stars 112 forks source link

named import does not work #53

Closed xatian closed 4 years ago

xatian commented 4 years ago

The first usage-example does not work for me. I created a new file in an empty directory, pasted your code and tried to run it.

$> npm init
....
$> npm install node-html-parser
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN test@1.0.0 No description
npm WARN test@1.0.0 No repository field.

+ node-html-parser@1.2.19
added 2 packages from 3 contributors and audited 2 packages in 0.409s
found 0 vulnerabilities

$> vim test.mjs
... (pasted the first usage-example) ...
$> node test.mjs
import { parse } from 'node-html-parser';
         ^^^^^
SyntaxError: The requested module 'node-html-parser' is expected to be of type CommonJS, which does not support named exports. CommonJS modules can be imported by importing the default export.
For example:
import pkg from 'node-html-parser';
const { parse } = pkg;
    at ModuleJob._instantiate (internal/modules/esm/module_job.js:97:21)
    at async ModuleJob.run (internal/modules/esm/module_job.js:135:5)
    at async Loader.import (internal/modules/esm/loader.js:178:24)

$> node --version
v14.4.0

Did I do something wrong? Thank you!

taoqf commented 4 years ago

I wish this will help you.