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

SyntaxError: Cannot use import statement outside a module #2050

Closed
TommyLeong opened this issue Mar 29, 2021 · 1 comment
Closed

SyntaxError: Cannot use import statement outside a module #2050

TommyLeong opened this issue Mar 29, 2021 · 1 comment

Comments

@TommyLeong
Copy link

TommyLeong commented Mar 29, 2021

Having issue while trying to run 'npm test'

Steps to Reproduce

  1. Create new project - npx react-native init testProject (RN 0.64.0)
  2. npm install --save react-native-code-push at project root
  3. cd ios pod install
  4. Run npm test at project root // npm test will success
  5. Append the code import codePush from "react-native-code-push"; at App.js
  6. Run npm test at project root // npm test will FAIL

Expected Behavior

Expect npm test to pass

Actual Behavior

Test failed after importing codePush

image

Environment

  • react-native-code-push version: "react-native-code-push": "^7.0.0"
  • react-native version: `react-native: 0.64.0 => 0.64.0
  • iOS/Android/Windows version: React-Native
  • Does this reproduce on a debug build or release build? - n/a
  • Does this reproduce on a simulator, or only on a physical device? - n/a

(The more info the faster we will be able to address it!)

@TommyLeong
Copy link
Author

Solution is to add transformIgnorePatterns your package.json.
Read more here

 "jest": {
    "preset": "react-native",
    "transformIgnorePatterns": [
      "node_modules/(?!(@react-native|react-native|react-native-code-push)/)"
    ]
  }

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