Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use --eval with ESM #2105

Open
STRd6 opened this issue Feb 4, 2024 · 0 comments
Open

Can't use --eval with ESM #2105

STRd6 opened this issue Feb 4, 2024 · 0 comments

Comments

@STRd6
Copy link

STRd6 commented Feb 4, 2024

Search Terms

input-type=module

Expected Behavior

ts-node -e "import 'package.json'"

import statements should work from CLI.

Actual Behavior

node:internal/errors:490
    ErrorCaptureStackTrace(err);
    ^

Error [ERR_INPUT_TYPE_NOT_ALLOWED]: --input-type can only be used with string input via --eval, --print, or STDIN
    at new NodeError (node:internal/errors:399:5)
    at defaultResolve (node:internal/modules/esm/resolve:1052:25)
    at nextResolve (node:internal/modules/esm/loader:163:28)
    at resolve (/home/daniel/.nvm/versions/node/v19.7.0/lib/node_modules/ts-node/dist/child/child-loader.js:15:125)
    at nextResolve (node:internal/modules/esm/loader:163:28)
    at ESMLoader.resolve (node:internal/modules/esm/loader:835:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:416:18)
    at ESMLoader.import (node:internal/modules/esm/loader:517:22)
    at node:internal/modules/run_main:56:28
    at loadESM (node:internal/process/esm_loader:94:11) {
  code: 'ERR_INPUT_TYPE_NOT_ALLOWED'

Steps to reproduce the problem

ts-node -e "import 'package.json'"

Trying with input-type=module also does not work. It is not recognized as an option to ts-node.

https://nodejs.org/api/cli.html#--input-typetype

Minimal reproduction

Specifications

ts-node v10.9.2
node v19.7.0
compiler v5.3.3

  • tsconfig.json, if you're using one:
{
  "compilerOptions": {
    "target": "ESNext",
    "module": "ESNext",
    "strict": true,
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "resolveJsonModule": true,
  },
  "ts-node": {
    "esm": true,
  }
}
  • package.json:
{
  "type": "module"
}
  • Operating system and version: Linux 5.10.16.3-microsoft-standard-WSL2 x86_64 x86_64 x86_64 GNU/Linux
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant