node.js - react 原生初始化错误

标签 node.js ubuntu reactjs react-native

我正在尝试将 React-native 安装到我的 ubuntu 14.04。我已成功安装react-native-cli ,但是当我尝试运行 react-native init reactApp trene 是一个错误:

pavlov@pavlov-System-Product-Name:~$ node -v
v0.12.7
pavlov@pavlov-System-Product-Name:~$ react-native init reactApp
prompt: Directory reactApp already exist. Continue?:  (no) y
This will walk you through creating a new React Native project in /home/pavlov/reactApp
Installing react-native package from npm...
You are currently running Node v0.12.7 but React Native requires >=4. Please use a supported version of Node.
See https://facebook.github.io/react-native/docs/getting-started.html
/home/pavlov/reactApp/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] (/home/pavlov/reactApp/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> (/home/pavlov/reactApp/node_modules/react-native/cli.js:15:18)
    at Module._compile (module.js:460:26)

我该如何解决?

最佳答案

您肯定需要安装 Node 4.0 或更高版本。实际上它甚至在你的控制台输出中说出来。

这是我在 Ubuntu 上安装 Node 的方法:

sudo apt-get install curl
curl --silent --location https://deb.nodesource.com/setup_4.x | sudo bash -
sudo apt-get install nodejs

祝你好运!

关于node.js - react 原生初始化错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33831391/

相关文章:

node.js - Nodejs : How to avoid async call in nodejs inside loop?

node.js - 将数据从 Node js Controller 连续流式传输到网页

networking - 使用 tor 作为 SOCKS5 代理与 python urllib2 或 mechanize

javascript - 在React中重新加载页面时如何避免404错误?

reactjs - 在 useEffect 或类似中使用指示 prop 的最佳实践

node.js - Google Oauth 交换代码、刷新 token 和访问 token

javascript - 在 Node.js 中的函数中访问 __dirname 是否被视为不纯代码?

javascript - 聚合日志并稍后写入文件,而无需直接写入文件

git - 如何制作水平可扩展的 Git 解决方案

ubuntu - cron 每天什么时间运行? (在 EC2 Ubuntu 上)