0

Today I have tried to create a new project and I am facing this problem It was working last day.

I have used this command "react-native init appname"

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 (E:\react-apps\reactapptest\testapp\node_modules\pirates\lib\index.js:91:24)
    at Module._extensions..js (module.js:663:10)
    at Object.newLoader [as .js] (E:\react-apps\reactapptest\testapp\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)

Please help me to fix tis.

3 Answers 3

1

You can simply use CRNA it is much better and easy to use.

$ npm i -g create-react-native-app
$ create-react-native-app appname
$ cd appname
$ npm start
Sign up to request clarification or add additional context in comments.

Comments

0

First, make sure that you have installed babel core and loader by using:

$ npm install --save-dev babel-loader babel-core

So the correct loader is babel-loader and not babel. The config should be:

module: {
  loaders: [
    { test: /\.js$/, exclude: /node_modules/, loader: "babel-loader" }
  ]
}

Actually you need to tell babel to transform your code.

Pre-6.x, Babel enabled certain transformations by default. However, Babel 6.x does not ship with any transformations enabled. You need to explicitly tell it what transformations to run. The simplest way to do this is by using a preset, such as the ES2015 Preset. You can install it with.

$ npm install babel-preset-es2015 --save-dev

After preset installed you have to enable it.

Create a .babelrc config in your project root and enable some plugins.

Assuming you have installed the ES2015 Preset, in order to enable it you have to define it in your .babelrc file, like this:

{
  "presets": ["es2015"]
}

Details in Babel Setup page.

Comments

0

Reinstall react-native-cli it may help

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.