如果您现在使用create-react-native-app
,该错误似乎已修复。现在使用react 0.55.2。
我们有一个正在使用react native构建的项目。
当我从网站运行以下命令时:
create-react-native-app AwesomeProject
然后我运行npm start
,它运行完美。
如果我更改了包裹(我添加了这一行):
"react-native-form-builder": "^1.0.15",
然后我运行npm install
,然后运行npm start
,我得到了这个错误:
C:\everforms>npm start
> everforms@0.1.0 start C:\everforms
> react-native-scripts start
11:57:29: Starting packager...
***ERROR STARTING PACKAGER***
No issue with doctor-npm-version
No issue with doctor-watchman-version
No issue with doctor-problem-checking-watchman-version
No issue with doctor-both-app-and-exp-json
No issue with doctor-schema-validation
No issue with doctor-validate-asset-fields
No issue with doctor-schema-validation-exception
No issue with doctor-unversioned
No issue with doctor-versions-endpoint-failed
No issue with doctor-invalid-sdk-version
No issue with doctor-node-modules-missing
No issue with doctor-react-native-not-installed
C:\everforms\node_modules\react-native\local-cli\cliEntry.js:30
import type {CommandT} from './commands';
^^^^^^
SyntaxError: Unexpected token import
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:616:28)
at Module._compile (C:\everforms\node_modules\pirates\lib\index.js:91:24)
at Module._extensions..js (module.js:663:10)
at Object.newLoader [as .js] (C:\everforms\node_modules\pirates\lib\index.js:96:7)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
11:57:35: Error starting packager: Error: Metro Bundler process exited with code 1
at ChildProcess.<anonymous> (C:\xdl@50.5.0\src\Project.js:1215:14)
at Generator.next (<anonymous>)
at step (C:\everforms\node_modules\xdl\build\Project.js:1768:191)
at C:\everforms\node_modules\xdl\build\Project.js:1768:437
at new Promise (<anonymous>)
at ChildProcess.<anonymous> (C:\everforms\node_modules\xdl\build\Project.js:1768:99)
at ChildProcess.packagerProcess.once (C:\xdl@50.5.0\src\Project.js:1213:5)
at Object.onceWrapper (events.js:317:30)
at emitTwo (events.js:126:13)
at ChildProcess.emit (events.js:214:7)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! everforms@0.1.0 start: `react-native-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the everforms@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\alber\AppData\Roaming\npm-cache\_logs\2018-07-05T09_57_35_135Z-debug.log
为什么会这样?
答案 0 :(得分:2)
此错误是react-native 0.56中的一个新错误,会影响Windows用户。为了解决这个问题,您可以创建一个具有其他本机版本的项目:
react-native init --version="0.55.4" MyNewApp
您可以在this GitHub issue中查看更多信息。
答案 1 :(得分:1)
在Windows上,0.56
版本的react-native似乎是一个问题。
它在OSX和Linux上运行良好。 自2天以来,Github上已打开issue。