3

react-native start command gives error.Genrated error is given below. Please help me.

react-native start 

/usr/lib/node_modules/react-native/local-cli/server/checkNodeVersion.js:43
    );
    ^

SyntaxError: Unexpected token )
    at createScript (vm.js:56:10)
    at Object.runInThisContext (vm.js:97:10)
    at Module._compile (module.js:549:28)
    at Object.Module._extensions..js (module.js:586:10)
    at Module.load (module.js:494:32)
    at tryModuleLoad (module.js:453:12)
    at Function.Module._load (module.js:445:3)
    at Module.require (module.js:504:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/usr/lib/node_modules/react-native/local-cli/cli.js:17:1)
Ravi Malviya
  • 121
  • 1
  • 13
  • can you put `script` section of `package.json`. If you have not edited anything in package.json`s script then try `npm start` – Revansiddh Jul 13 '18 at 05:50
  • "start": "node node_modules/react-native/local-cli/cli.js start" this is included in my script section. Actually before some days its work perfectly but after some system configration its give error like this. – Ravi Malviya Jul 13 '18 at 05:56
  • use `npm start` or `npm run start`. Hope it wil work – Revansiddh Jul 13 '18 at 05:58
  • may be this is because react native version . if you are using version 56 then check this answer https://stackoverflow.com/a/51246527/6359528 – Jay Thummar Jul 13 '18 at 06:56

6 Answers6

2

I found out that if you have installed nvm to manage different node versions, is showing one version but using another from behind, I also have problems with my global brew node installation, so I had reinstalled again from scratch. As a general tip, unload the nvm and work with the npm global installation.

2

Update your nodejs should fix

  1. sudo npm cache clean -f (force) clear you npm cache
  2. sudo npm install -g n install "n" (this might take a while)
  3. sudo n stable upgrade to lastest version
Ken Zira
  • 1,170
  • 2
  • 10
  • 12
0

I checked the file "/usr/lib/node_modules/react-native/local-cli/server/checkNodeVersion.js:43" and found that "React Native runs on Node 8.0 or newer." But my node vesion was 6.0 ,so that the problem.

Ravi Malviya
  • 121
  • 1
  • 13
0

The error belongs with node js version. node --v in cmd will show version less than 8. Update your node version by installing nvm. This will help you update version. https://stackoverflow.com/a/7718438/9090200

0

In-case you are using nvm to install a new version of node.

It's important that you will use nvm alias default node so it will be the default version while opening new shells.

D_R
  • 4,894
  • 4
  • 45
  • 62
0

React Native runs on Node 8.0 or newer If you are using nvm then set "nvm alias default >=8.X.X" like "nvm alias default 8.0.0" Re-open your terminal and try it again.