search

Home  >  Q&A  >  body text

node.js - React-native npm start启动报错!

我是跟着RN官网的教程来玩的:
https://facebook.github.io/react-native/docs/getting-started.html#content
求解惑

启动时在终端看到的错误信息如下

/Users/yiwang/Documents/react_native/AwesomeProject/node_modules/react-native/local-cli/cli.js:56
const setupEnvScript = /^win/.test(process.platform)
^^^^^
SyntaxError: Use of const in strict mode.

at exports.runInThisContext (vm.js:73:16)
at Module._compile (module.js:443:25)
at Module._extensions..js (module.js:478:10)
at Object.require.extensions.(anonymous function) [as .js] (/Users/yiwang/Documents/react_native/AwesomeProject/node_modules/react-native/node_modules/babel-core/lib/api/register/node.js:214:7)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/Users/yiwang/Documents/react_native/AwesomeProject/node_modules/react-native/cli.js:15:18)
伊谢尔伦伊谢尔伦2777 days ago554

reply all(2)I'll reply

  • 巴扎黑

    巴扎黑2017-04-17 13:03:45

    Upgrade node to 4.1 or above.

    reply
    0
  • 巴扎黑

    巴扎黑2017-04-17 13:03:45

    You need to upgrade node, but if you are using nvm to manage node version.
    Use node use <different versions> directly. If your system version is lower than the version required by react-native, there will also be problems.
    Because react-native will open a new window when it starts, if you do not configure it in a configuration file such as .xxx, there will still be problems.

    1. It is recommended to use nvm to manage node (it is very likely that you do not want to abandon the project of the old version of node for some reason);
    2. Use nvm alias default stable (the latest version is used as the default version here, required Use nvm install stable to install the latest version)

    Wish you good luck!

    reply
    0
  • Cancelreply