crazycodeboy / react-native-splash-screen

A splash screen for react-native, hide when application loaded ,it works on iOS and Android.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SyntaxError: Cannot use import statement outside a module

houlasovansela18 opened this issue · comments

commented

Result from react-native info
System:
OS: macOS 13.2.1
CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
Memory: 2.36 GB / 16.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 16.15.1 - /usr/local/bin/node
Yarn: 1.22.19 - ~/.yarn/bin/yarn
npm: 8.11.0 - /usr/local/bin/npm
Watchman: 2023.03.27.00 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.12.0 - /Users/houlasovansela/.rvm/gems/ruby-2.7.6/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 22.4, iOS 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4
Android SDK:
API Levels: 27, 29, 33
Build Tools: 29.0.2, 30.0.3, 33.0.0
System Images: android-27 | Google APIs Intel x86 Atom, android-29 | Android TV Intel x86 Atom, android-29 | ARM 64 v8a, android-29 | Intel x86 Atom, android-29 | Intel x86 Atom_64, android-29 | Google APIs ARM 64 v8a, android-29 | Google APIs Intel x86 Atom, android-29 | Google APIs Intel x86 Atom_64, android-29 | Google Play ARM 64 v8a, android-29 | Google Play Intel x86 Atom, android-29 | Google Play Intel x86 Atom_64, android-31 | Google APIs Intel x86 Atom_64
Android NDK: Not Found
IDEs:
Android Studio: 2022.1 AI-221.6008.13.2211.9619390
Xcode: 14.3/14E222b - /usr/bin/xcodebuild
Languages:
Java: 13.0.2 - /usr/bin/javac
npmPackages:
@react-native-community/cli: ^11.1.1 => 11.1.1
react: 18.2.0 => 18.2.0
react-native: 0.71.4 => 0.71.4
react-native-macos: ^0.68.68 => 0.68.68
npmGlobalPackages:
react-native: Not Found

I am using "react-native-splash-screen": "^3.3.0",

This error come from when i run npm run test and the result is

` FAIL tests/App-test.tsx
● Test suite failed to run

Jest encountered an unexpected token

Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.

Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.

By default "node_modules" folder is ignored by transformers.

Here's what you can do:
 • If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/ecmascript-modules for how to enable it.
 • If you are trying to use TypeScript, see https://jestjs.io/docs/getting-started#using-typescript
 • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
 • If you need a custom transformation specify a "transform" option in your config.
 • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

You'll find more details and examples of these config options in the docs:
https://jestjs.io/docs/configuration
For information about custom transformations, see:
https://jestjs.io/docs/code-transformation

Details:

/Users/houlasovansela/Documents/Workspace/tovtrip_v2/node_modules/react-native-splash-screen/index.js:12
import { NativeModules } from 'react-native';
^^^^^^

SyntaxError: Cannot use import statement outside a module

  2 | import {NavigationContainer} from "@react-navigation/native";
  3 | import {StatusBar, useColorScheme} from "react-native";
> 4 | import SplashScreen from "react-native-splash-screen";
    | ^
  5 | import AppStack from "./app/pages/AppStack";
  6 | import * as AppCenter from "appcenter";
  7 |

  at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1495:14)
  at Object.require (App.tsx:4:1)
  at Object.require (__tests__/App-test.tsx:7:1)

Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 0.887 s
Ran all test suites.
error Command failed with exit code 1.`

create a mock file for react-native-splash-screen