简体   繁体   中英

“react-native start” command gives error

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)

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.

Update your nodejs should fix

  1. sudo npm cache clean -f (force) clear you npm cache
  2. sudo npm install -gn install "n" (this might take a while)
  3. sudo n stable upgrade to lastest version

我检查了文件“/usr/lib/node_modules/react-native/local-cli/server/checkNodeVersion.js:43”,发现“ React Native在Node 8.0或更新版本上运行。 ”但是我的节点vesion是6.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

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.

React Native在Node 8.0或更高版本上运行如果您使用的是nvm,则将“nvm alias default> = 8.XX”设置为“nvm alias default 8.0.0”重新打开终端并再次尝试。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM