就在几天前,react更新0.56.0版本,window上出现BUG,具体如下:
F:\AAAA\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 (F:\AAAA\node_modules\pirates\lib\index.js:91:24)
at Module._extensions..js (internal/modules/cjs/loader.js:713:10)
at Object.newLoader [as .js] (F:\AAAA\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)
解决方案:
react-native init MyApp --version 0.55.4
显示结果:
Done in 13.28s.
To run your app on iOS:
cd F:\MyApp
react-native run-ios
- or -
Open ios\MyApp.xcodeproj in Xcode
Hit the Run button
To run your app on Android:
cd F:\MyApp
Have an Android emulator running (quickest way to get started), or a device connected
react-native run-android