dotoritos-kim/dxf-json

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

Closed this issue · 1 comments

velle commented

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):

  • OS: Ubuntu 22.04 LTS
  • Node.js v21.6.1
  • NPM v10.2.4
  • dxf-json@0.0.17

@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.