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

使用 ts-node 时报错 Cannot use import statement outside a module #6

Open
Cansiny0320 opened this issue Dec 31, 2021 · 0 comments

Comments

@Cansiny0320
Copy link
Owner

Cansiny0320 commented Dec 31, 2021

原因:tsconfig 中的 module 值设置过高(ES2015以上) 应该是 ts-node 的 bug (ts-node 版本 v10.4.0)
解决方法:TypeStrong/ts-node#922 (comment)
对于 ts-node 单独设置

  "ts-node": {
    // these options are overrides used only by ts-node
    // same as our --compilerOptions flag and our TS_NODE_COMPILER_OPTIONS environment variable
    "compilerOptions": {
      "module": "commonjs"
    }
  },
@Cansiny0320 Cansiny0320 changed the title 使用 ts-node 时 tsconfig 中的 module 值设置过高(ES2015以上) 会报错 使用 ts-node 时报错 Cannot use import statement outside a module Dec 31, 2021
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