`Cannot use import statement outside a module` when combining RN and ts-node

爷,独闯天下 提交于 2021-01-29 21:46:38

问题


I created a small CLI tool to automate some process on my React Native project. Recently I had to update the RN from 0.61.4 to 0.63.2 to address some iOS issues. Since this update, the CLI is not working anymore.

The errors are:

yarn ts-node -r tsconfig-paths/register ./scripts/check
import typeof AccessibilityInfo from './Libraries/Components/AccessibilityInfo/AccessibilityInfo';
^^^^^^
SyntaxError: Cannot use import statement outside a module

and

yarn ts-node -r esm -r tsconfig-paths/register ./scripts/check
import typeof AccessibilityInfo from './Libraries/Components/AccessibilityInfo/AccessibilityInfo';
       ^
SyntaxError: Invalid or unexpected token

I've tried a bunch of solutions but feels that I fix A and break B, and vice-versa. Important to mention that some files from this CLI are shared with the RN app, and the RN app is working fine.

I believe I need to clear the flow typings from RN, but @babel/plugin-transform-flow-strip-types did not help

来源:https://stackoverflow.com/questions/63999303/cannot-use-import-statement-outside-a-module-when-combining-rn-and-ts-node

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!