react-native: React native 0.56.* - "Unexpected identifier"
- Review the documentation: https://facebook.github.io/react-native
- Search for existing issues: https://github.com/facebook/react-native/issues
- Use the latest React Native release: https://github.com/facebook/react-native/releases
Environment
Run react-native info
in your terminal and paste its contents here.
C:\Projects\AwesomeProject>react-native info
C:\Projects\AwesomeProject\node_modules\react-native\local-cli\cliEntry.js:30
import type {CommandT} from './commands';
^^^^
SyntaxError: Unexpected identifier
at new Script (vm.js:74:7)
at createScript (vm.js:246:10)
at Object.runInThisContext (vm.js:298:10)
at Module._compile (internal/modules/cjs/loader.js:670:28)
at Module._compile (C:\Projects\AwesomeProject\node_modules\pirates\lib\index.js:91:24)
at Module._extensions..js (internal/modules/cjs/loader.js:713:10)
at Object.newLoader [as .js] (C:\Projects\AwesomeProject\node_modules\pirates\lib\index.js:96:7)
at Module.load (internal/modules/cjs/loader.js:612:32)
at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
at Function.Module._load (internal/modules/cjs/loader.js:543:3)
So manually:
- Windows 10.1803.17134.112 x64
- Node 10.5.0
- Npm 6.1.0
[skip envinfo]
Description
Any attempt at react-native start
or any other react-native cli feature - results in:
C:\Projects\AwesomeProject>react-native info
C:\Projects\AwesomeProject\node_modules\react-native\local-cli\cliEntry.js:30
import type {CommandT} from './commands';
^^^^
SyntaxError: Unexpected identifier
Reproducible Demo
create-react-native-app
npm run eject
react-native-git-upgrade next
- Need to add
"babel-preset-react-native": "^5.0.1"
to package.json according to the CHANGELOG. - Add
"babel-preset-react-native"
preset to.babelrc
npm i
react-native start
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 8
- Comments: 59 (12 by maintainers)
Here the same problem !!!
if you need to create a project you can use the latest stable version directly, it worked for me!
react-native init --version="0.55.4" MyNewApp
For me it resolved the initial issue (so did hotfixing it myself from previous posts). but both solutions lead me to another issue, i cant realy tell if its related
React Native Environment Info: System: OS: Windows 7 CPU: x64 Intel® Core™ i5-5200U CPU @ 2.20GHz Memory: 3.20 GB / 11.92 GB Binaries: Yarn: 1.7.0 - C:\Program Files (x86)\Yarn\bin\yarn.CMD npm: 6.1.0 - C:\Program Files\nodejs\npm.CMD IDEs: Android Studio: Version 1.5.0.0 AI-141.2456560
node -v v9.10.1
this is done from a clean
react-native init Test056
react-native run-android
This issue was already reported multiple times in early rc stages of 0.56 (i guess it was even 0.56-rc.0). Did my best to investigate and resolve this issue, but really hadn’t enough time to fix
metro
etc.To cite myself from 20 days ago:
So, the react-native core team is aware of this issue and knew that react-native 0.56 is broken on windows when they decided to make the
0.56.0
release, but they wanted to go fast with this release. So, just keep calm and hope the best for0.56.1
.------------Final Solution------------ We can’t use RN0.56. To run your code, you should downgrade RN to 0.55.4. No way else!!!
ok, this is pretty serious. I think it’s time to warn the big guys to inspect on this (hope I’ll do nothing wrong) @brentvatne
@danielgindi The “rc” from the title can be removed, this problem affects also the current 0.56 released today
Hello everyone! A new release of metro, 0.38.2, has been released and it should fix this issue. Since RN 0.56.0 depends on metro version
This means that to apply the fix you would simply need to remove the node_modules (and if they’re using yarn.lock you’ll need to also clean metro from the lock file) and reinstall.
I’ll unlock the issue in order to get some feedback that this new release of metro actually fixes for you all, since there is always the scenario in which we haven’t covered every possible Win configuration during our tests.
@johakr I’m just surprised a release took place with a whole platform being broken. Without a FAT warning in the release notes or potentially even the CLI client on breakage, this means that you impose wasted time on every developer who happens to be working on a Windows machine, which quickly amounts to thousands of hours evaporating into thin air. Hence the surprise. Apart from that, all good (and calm 😉 on my side, I’ll just keep sitting on the stable 0.55.x version 😃
@DanielEncina
react-native init --version="0.55.4" MyNewApp
it works, thank you !Same problem here. It started when I deleted my node_modules folder and run npm install.
EDIT: I fixed it opening my package.json and change the react-native version from 0.56.0 to 0.55.4, then I execute npm install again and it worked.
I think it’s a Windows specific problem, I’m running into the same issue.
It’s been reported here: https://github.com/facebook/react-native/issues/19669 https://github.com/facebook/react-native/issues/19654
And there’s a pull request pending here: https://github.com/gengjiawen/react-native/tree/feature/RNTester_start
Unfortunately, I could not get that to work either on my end.
Anyone had success beating this problem?