dotoritos-kim / dxf-json

perfect dxf parser
GNU General Public License v3.0
56 stars 3 forks source link

SyntaxError: Cannot use import statement inside the Node.js REPL #4

Closed velle closed 8 months ago

velle commented 8 months ago

Describe the bug A clear and concise description of what the bug is.

To Reproduce

Unable to import/require dxf-json:

I install dxf-json locally (the way I believe it should be done):

$ cd ~
$ mkdir test
$ cd test
~/test$ nvm use stable
Now using node v21.6.1 (npm v10.2.4)
$ npm i dxf-json

added 432 packages in 23s

I then test if a script is able to import dxf-json (the way I believe it should be done):

$ node
Welcome to Node.js v21.6.1.
Type ".help" for more information.
> dxf=require('dxf-json')
/home/velle/test/node_modules/dxf-json/src/index.ts:1
import DxfParser from './parser/DxfParser'
^^^^^^

Uncaught:
SyntaxError: Cannot use import statement inside the Node.js REPL, alternatively use dynamic import:
>

Expected behavior

No error.

Desktop (please complete the following information):

Phryxia commented 8 months ago

@velle cc @dotoritos-kim

Thank you for raising the issue. I think this is becasue dxf-json doesn't support ESM currently. But I think we must do that because it's ECMA standard. I'll inspect this and work if further repair is required for this asap.