#How do I use top level await, TS and import at the same time

5 messages · Page 1 of 1 (latest)

dusk wolf
#

What else do I need to change to make it work?

#

using tsx currently

d:\...\node_modules\.pnpm\paper@0.12.17\node_modules\paper\dist\paper-full.js:14652
                return set(document.createElementNS(svg, tag), attributes, formatter);
                                    ^


TypeError: Cannot read properties of undefined (reading 'createElementNS')
    at Object.create (d:\...\node_modules\.pnpm\paper@0.12.17\node_modules\paper\dist\paper-full.js:14652:23)
    at Project2.exportSVG (d:\...\node_modules\.pnpm\paper@0.12.17\node_modules\paper\dist\paper-full.js:15116:26)
    at <anonymous> (d:\...\src\pixilate.ts:45:15)

Node.js v20.8.0

which shouldn't happen
tho previous attempt of using ts-node didn't work D:

#
  • Tried ts-node file.ts arg,
    with the current settings,
    it will give TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for D:\...\file.ts
#
  • Tried ts-node file.ts arg,
    with "type": "module" removed in package.json
    Error: ```js
    TSError: ⨯ Unable to compile TypeScript:
    src/pixilate.ts:42:11 - error TS1309: The current file is a CommonJS module and cannot use 'await' at the top level.
#

What should I do?