react-native: react-native init AwesomeProject SyntaxError :
react-native init AwesomeProject
no longer works for me. It did just a few hours ago. I am working on a macbook pro and I have tried:
- Restarting
- Removing and Reinstalling
react-native-cli
- Installing Yarn
- Different node js versions with
nvm
I always get the exact same error:
Last login: Thu Dec 8 17:07:25 on ttys000
192.168.0.104
javac 1.8.0_111
node version v6.9.2
npm version 3.10.9
~ => cd documents
documents => react-native init AwesomeProject
This will walk you through creating a new React Native project in /Users/alexbanks/Documents/AwesomeProject
Using yarn v0.17.10
Installing react-native...
/Users/alexbanks/Documents/AwesomeProject/node_modules/react-native/local-cli/util/Config.js:43
cwd: string,
^
SyntaxError: Unexpected token :
at Object.exports.runInThisContext (vm.js:76:16)
at Module._compile (module.js:542:28)
at loader (/Users/alexbanks/Documents/AwesomeProject/node_modules/babel-register/lib/node.js:144:5)
at Object.require.extensions.(anonymous function) [as .js] (/Users/alexbanks/Documents/AwesomeProject/node_modules/babel-register/lib/node.js:154:7)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/Users/alexbanks/Documents/AwesomeProject/node_modules/react-native/local-cli/cliEntry.js:13:16)
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 16
- Comments: 29 (4 by maintainers)
I was getting the same error. I hit Cmd-D and clicked
Debug JS Remotely
. The app refreshed and the syntax error was gone.If I turn off remote debugging, the error returns.
I already had the debugger window open from another project, but if you don’t: http://localhost:8081/debugger-ui
fallback to 0.38 to resolve this. react-native init MyProject --version 0.38.0
ping @grabbou
FYI - Until this gets resolved, you can use
rninit
(https://www.npmjs.com/package/rninit) to install using the previous version of react-native. This worked for me:rninit init mobile --source react-native@0.39.0
in file “node_modules/react-native/Libraries/Core/InitializeCore.js” delete ‘use strict’;
and it works
This issue seems fairly random. I ended up fixing it by effectively
touch
ingnode_modules/react-native/local-cli/util/Config.js
. I just opened the file up and changed one character, saved, then changed it back, and it started working.What is more odd is that this caused the packager to work correctly, but
watchman watch-del-all && rm -rf node_modules && npm cache clean && npm i
didn’t fix it.In my case, I have been on
react-native@0.38.1
the whole time, although I have run@0.39
in another project.This works for me.
@riyanpratama Please run
npm uninstall react-native
thennpm i react-native@0.38
I hope it will help you. But it is just a trick. Hope the bug wil be fixed soon !@riyanpratama You can roll back to version 0.38.0 as @sunnylqm said. It works for me
I have the same issue with
react-native: 0.39.1