问题
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