![](/img/trans.png)
[英]npx react-native init AwesomeProject error enolocal
[英]React-native init error
我正在嘗試將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
祝好運!
轉到https://nodejs.org/en/並下載最新版本,在本例中為v4.4.3。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.