#Cannot find native package 'readline'

1 messages · Page 1 of 1 (latest)

lament sleet
#

When I'm trying to run npm run debug (which turns into ts-node-esm --compiler ttypescript src/index.ts) I get an error:
https://pastebin.com/9cWd8YKZ

I'm using ttypescript and ttsc because of typia.
As for having package type module, it's because I'm using await globally (outside of a function).

src/index.ts

import * as Readline from "readline/promises";

const readline = Readline.createInterface({
  input: process.stdin,
  output: process.stdout,
});

while (true) {
  const command = await readline.question("Enter command:");
  if (command === "stop") {
    break;
  }
}

package.json:

{
  "type": "module",
  "main": "index.js",
  "scripts": {
    "rimraf": "./node_modules/rimraf/bin.js",
    "clean": "rimraf build/",
    "debug": "ts-node-esm --compiler ttypescript src/index.ts",
    "build": "npm run clean && ttsc",
    "start": "node build/index.js"
  },
  "devDependencies": {
    "@tsconfig/node16": "^1.0.3",
    "@types/node": "^18.14.2",
    "@typescript-eslint/eslint-plugin": "^5.0.0",
    "@typescript-eslint/parser": "^5.54.0",
    "eslint": "^8.0.1",
    "eslint-config-prettier": "^8.6.0",
    "eslint-config-standard-with-typescript": "^34.0.0",
    "eslint-plugin-import": "^2.25.2",
    "eslint-plugin-n": "^15.0.0",
    "eslint-plugin-promise": "^6.0.0",
    "prettier": "^2.8.4",
    "rimraf": "^4.2.0",
    "ts-node": "^10.9.1",
    "ttypescript": "^1.5.15",
    "typescript": "*"
  },
  "dependencies": {
    "typia": "^3.6.2",
  },
}

tsconfig.json:

{
  "extends": "@tsconfig/node16/tsconfig.json",
  "compilerOptions": {
    "esModuleInterop": true,
    "lib": ["es2021"],
    "module": "es2022",
    "target": "es2022",
    "outDir": "build",
    "plugins": [
      {
        "transform": "typia/lib/transform"
      }
    ],
    "strict": true
  }
}
ripe glen
#

@lament sleet That's a runtime error, so I guess check what version of node you're running?

#

Looks like the promises version of the API was added in v17