我正在尝试运行我的react-native应用程序,但不断出现以下错误。
Failed to load bundle(http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false) with error:(/Users/myname/myapp/index.js: Cannot find module 'babel/plugin-proposal-nullish-coalescing-operator' from '/Users/myname/myapp' (null))
__38-[RCTCxxBridge loadSource:onProgress:]_block_invoke.233
RCTCxxBridge.mm:422
invocation function for block in attemptAsynchronousLoadOfBundleAtURL(NSURL*, void (RCTLoadingProgress*) block_pointer, void (NSError*, RCTSource*) block_pointer)
__80-[RCTMultipartDataTask URLSession:streamTask:didBecomeInputStream:outputStream:]_block_invoke
-[RCTMultipartStreamReader emitChunk:headers:callback:done:]
-[RCTMultipartStreamReader readAllPartsWithCompletionCallback:progressCallback:]
-[RCTMultipartDataTask URLSession:streamTask:didBecomeInputStream:outputStream:]
_CFNetworkHTTPConnectionCacheSetLimit
__NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__
-[NSBlockOperation main]
__NSOPERATION_IS_INVOKING_MAIN__
-[NSOperation start]
__NSOPERATIONQUEUE_IS_STARTING_AN_OPERATION__
__NSOQSchedule_f
_dispatch_block_async_invoke2
_dispatch_client_callout
_dispatch_continuation_pop
_dispatch_async_redirect_invoke
_dispatch_root_queue_drain
_dispatch_worker_thread2
_pthread_wqthread
start_wqthread
这是我的package.json
{
"name": "Athalens",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"algoliasearch": "^3.30.0",
"lodash": "^4.17.10",
"react": "16.4.1",
"react-instantsearch": "^5.3.1",
"react-native": "^0.56.0",
"react-native-fetch-blob": "^0.10.8",
"react-native-firebase": "^5.1.0",
"react-native-keyboard-aware-scroll-view": "^0.7.0",
"react-native-linear-gradient": "^2.4.2",
"react-native-optimized-flatlist": "^1.0.4",
"react-native-router-flux": "^4.0.1",
"react-native-scalable-image": "^0.4.0",
"react-native-screenshot-detector": "^1.0.0",
"react-native-share": "^1.1.3",
"react-native-stripe-api": "^0.1.0",
"react-redux": "^5.0.7",
"redux": "^4.0.0",
"redux-thunk": "^2.3.0"
},
"devDependencies": {
"@babel/core": "^7.7.2",
"@babel/helper-plugin-utils": "^7.0.0",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.4.4",
"@babel/plugin-syntax-nullish-coalescing-operator": "^7.2.0",
"babel-jest": "23.4.2",
"babel-preset-react-native": "5.0.2",
"eslint-config-rallycoding": "^3.2.0",
"jest": "23.5.0",
"react-test-renderer": "16.4.1"
},
"jest": {
"preset": "react-native"
}
}
我在终端中遇到以下错误。
> npm WARN @babel/plugin-external-helpers@7.0.0-beta.47 requires a peer of @babel/core@7.0.0 beta.47 but none is installed. You must install peer dependencies yourself.
> npm WARN @babel/plugin-proposal-class-properties@7.0.0-beta.47 requires a peer
> of @babel/core@7.0.0-beta.47 but none is installed. You must install
> peer dependencies yourself. npm WARN
> @babel/plugin-proposal-object-rest-spread@7.0.0-beta.47 requires a
> peer of @babel/core@7.0.0-beta.47 but none is installed. You must
> install peer dependencies yourself. npm WARN
> @babel/plugin-proposal-optional-chaining@7.0.0-beta.47 requires a peer
> of @babel/core@7.0.0-beta.47 but none is installed. You must install
> peer dependencies yourself. npm WARN
> @babel/plugin-syntax-class-properties@7.0.0-beta.47 requires a peer of
> @babel/core@7.0.0-beta.47 but none is installed. You must install peer
> dependencies yourself. npm WARN
> @babel/plugin-syntax-dynamic-import@7.0.0-beta.47 requires a peer of
> @babel/core@7.0.0-beta.47 but none is installed. You must install peer
> dependencies yourself. npm WARN
> @babel/plugin-syntax-flow@7.0.0-beta.47 requires a peer of
> @babel/core@7.0.0-beta.47 but none is installed. You must install peer
> dependencies yourself. npm WARN @babel/plugin-syntax-jsx@7.0.0-beta.47
> requires a peer of @babel/core@7.0.0-beta.47 but none is installed.
> You must install peer dependencies yourself. npm WARN
> @babel/plugin-syntax-object-rest-spread@7.0.0-beta.47 requires a peer
> of @babel/core@7.0.0-beta.47 but none is installed. You must install
> peer dependencies yourself. npm WARN
> @babel/plugin-syntax-optional-chaining@7.0.0-beta.47 requires a peer
> of @babel/core@7.0.0-beta.47 but none is installed. You must install
> peer dependencies yourself. npm WARN
> @babel/plugin-transform-arrow-functions@7.0.0-beta.47 requires a peer
> of @babel/core@7.0.0-beta.47 but none is installed. You must install
> peer dependencies yourself. npm WARN
> @babel/plugin-transform-async-to-generator@7.0.0-beta.47 requires a
> peer of @babel/core@7.0.0-beta.47 but none is installed. You must
> install peer dependencies yourself. npm WARN
> @babel/plugin-transform-block-scoping@7.0.0-beta.47 requires a peer of
> @babel/core@7.0.0-beta.47 but none is installed. You must install peer
> dependencies yourself. npm WARN
> @babel/plugin-transform-classes@7.0.0-beta.47 requires a peer of
> @babel/core@7.0.0-beta.47 but none is installed. You must install peer
> dependencies yourself. npm WARN
> @babel/plugin-transform-computed-properties@7.0.0-beta.47 requires a
> peer of @babel/core@7.0.0-beta.47 but none is installed. You must
> install peer dependencies yourself. npm WARN
> @babel/plugin-transform-destructuring@7.0.0-beta.47 requires a peer of
> @babel/core@7.0.0-beta.47 but none is installed. You must install peer
> dependencies yourself. npm WARN
> @babel/plugin-transform-exponentiation-operator@7.0.0-beta.47 requires
> a peer of @babel/core@7.0.0-beta.47 but none is installed. You must
> install peer dependencies yourself. npm WARN
> @babel/plugin-transform-flow-strip-types@7.0.0-beta.47 requires a peer
> of @babel/core@7.0.0-beta.47 but none is installed. You must install
> peer dependencies yourself. npm WARN
> @babel/plugin-transform-for-of@7.0.0-beta.47 requires a peer of
> @babel/core@7.0.0-beta.47 but none is installed. You must install peer
> dependencies yourself. npm WARN
> @babel/plugin-transform-function-name@7.0.0-beta.47 requires a peer of
> @babel/core@7.0.0-beta.47 but none is installed. You must install peer
> dependencies yourself. npm WARN
> @babel/plugin-transform-literals@7.0.0-beta.47 requires a peer of
> @babel/core@7.0.0-beta.47 but none is installed. You must install peer
> dependencies yourself. npm WARN
> @babel/plugin-transform-modules-commonjs@7.0.0-beta.47 requires a peer
> of @babel/core@7.0.0-beta.47 but none is installed. You must install
> peer dependencies yourself. npm WARN
> @babel/plugin-transform-object-assign@7.0.0-beta.47 requires a peer of
> @babel/core@7.0.0-beta.47 but none is installed. You must install peer
> dependencies yourself. npm WARN
> @babel/plugin-transform-parameters@7.0.0-beta.47 requires a peer of
> @babel/core@7.0.0-beta.47 but none is installed. You must install peer
> dependencies yourself. npm WARN
> @babel/plugin-transform-react-display-name@7.0.0-beta.47 requires a
> peer of @babel/core@7.0.0-beta.47 but none is installed. You must
> install peer dependencies yourself. npm WARN
> @babel/plugin-transform-react-jsx@7.0.0-beta.47 requires a peer of
> @babel/core@7.0.0-beta.47 but none is installed. You must install peer
> dependencies yourself. npm WARN
> @babel/plugin-transform-react-jsx-source@7.0.0-beta.47 requires a peer
> of @babel/core@7.0.0-beta.47 but none is installed. You must install
> peer dependencies yourself. npm WARN
> @babel/plugin-transform-regenerator@7.0.0-beta.47 requires a peer of
> @babel/core@7.0.0-beta.47 but none is installed. You must install peer
> dependencies yourself. npm WARN
> @babel/plugin-transform-shorthand-properties@7.0.0-beta.47 requires a
> peer of @babel/core@7.0.0-beta.47 but none is installed. You must
> install peer dependencies yourself. npm WARN
> @babel/plugin-transform-spread@7.0.0-beta.47 requires a peer of
> @babel/core@7.0.0-beta.47 but none is installed. You must install peer
> dependencies yourself. npm WARN
> @babel/plugin-transform-sticky-regex@7.0.0-beta.47 requires a peer of
> @babel/core@7.0.0-beta.47 but none is installed. You must install peer
> dependencies yourself. npm WARN
> @babel/plugin-transform-template-literals@7.0.0-beta.47 requires a
> peer of @babel/core@7.0.0-beta.47 but none is installed. You must
> install peer dependencies yourself. npm WARN
> @babel/plugin-transform-unicode-regex@7.0.0-beta.47 requires a peer of
> @babel/core@7.0.0-beta.47 but none is installed. You must install peer
> dependencies yourself.
我的.babelrc文件如下所示。
{
"presets": ["module:metro-react-native-babel-preset"],
"plugins": ["babel/plugin-proposal-nullish-coalescing-operator"]
}
我已按照另一个问题的答案进行操作,但仍然无法正常工作。 syntax 'nullishCoalescingOperator' isn't currently enabled
我已经坚持了将近2天,希望能获得一些帮助。