Question Detail

SyntaxError: Unexpected token import in React-Native

5 years ago Views 3691 Visit Post Reply

When I try to create a new project in React-Native I am getting below error and created an incomplete project folder.

 

import type {CommandT} from './commands';

^^^^^^

SyntaxError: Unexpected token import
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:616:28)
    at Module._compile (C:\...\reactNative\ProjectName\node_modules\pirates\lib\index.js:91:24)
    at Module._extensions..js (module.js:663:10)
    at Object.newLoader [as .js] (C:\...\reactNative\ProjectName\node_modules\pirates\lib\index.js:96:7)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)

 


Thread Reply

Hemant Sharma

- 5 years ago

I also faced this issue and search for this issue then I found this error is coming from backend issue is new React-Native Version you have to wait for the new version or downgrade your react-native Version to work.

 

follow me to woking React-Native project folder with android and Ios folder (Complete React-Native Project

> react-native init --version="0.44.0" APP_NAME

after going in your App_Name folder update your NPM

> npm install npm@latest

Note:- Hope so you have already Installed Node.js

 

after successful above commands run your Hello World React-Native Project

 

Open the System pane under System and Security in the Windows Control Panel, then click on Change settings... Open the Advanced tab and click on Environment Variables... Click on New... to create a new ANDROID_HOME user variable that points to the path to your Android SDK:

ANDROID_HOME Environment Variable

Hemant Sharma

- 5 years ago

I also faced this issue and search for this issue then I found this error is coming from backend issue is new React-Native Version you have to wait for the new version or downgrade your react-native Version to work.

 

follow me to woking React-Native project folder with android and Ios folder (Complete React-Native Project

> react-native init --version="0.44.0" APP_NAME

after going in your App_Name folder update your NPM

> npm install npm@latest

Note:- Hope so you have already Installed Node.js

 

after successful above commands run your Hello World React-Native Project

 

Open the System pane under System and Security in the Windows Control Panel, then click on Change settings... Open the Advanced tab and click on Environment Variables... Click on New... to create a new ANDROID_HOME user variable that points to the path to your Android SDK:

ANDROID_HOME Environment Variable