简体   繁体   English

Nextjs 不适用于 react-native 和 expo

[英]Nextjs not working with react-native and expo

I am trying to set up a expo project with nextjs.我正在尝试使用 nextjs 设置 expo 项目。 I first ran the expo init command expo init.我首先运行了 expo init 命令expo init. and set up the project in my directory.并在我的目录中设置项目。 This seems to work fine.这似乎工作正常。 Then I followed the steps here https://docs.expo.dev/guides/using-nextjs/ under the adding nextjs to expo projects and did yarn add -D @expo/next-adapter then yarn next-expo and then yarn next dev .然后我按照这里的步骤https://docs.expo.dev/guides/using-nextjs/在添加 nextjs 到 expo 项目和didter yarn add -D @expo/next-adapter yarn next-expo @then-ada/ yarn next dev Then it just spews out a bunch of warnings.然后它只是喷出一堆警告。 Most notably the following 2 repeating.最值得注意的是以下2次重复。 I can't post the entire warning because it is too long.我无法发布整个警告,因为它太长了。 What is the deal and what am I doing wrong?交易是什么,我做错了什么? Did I miss something?我错过了什么? Is this not production ready and should I just forget this?这还没有准备好生产吗?我应该忘记这个吗? I don't know where to start when it comes to fixing these errors.在修复这些错误时,我不知道从哪里开始。

Warning: useTransformReactJsxExperimental has been renamed to useTransformReactJSXExperimental (capitalized JSX) in react-native@0.64.0
Though the "loose" option was set to "false" in your @babel/preset-env config, it will not be used for @babel/plugin-proposal-private-property-in-object since the "loose" mode option was set to "true" for @babel/plugin-proposal-class-properties.
The "loose" option must be the same for @babel/plugin-proposal-class-properties, @babel/plugin-proposal-private-methods and @babel/plugin-proposal-private-property-in-object (when they are enabled): you can silence this warning by explicitly adding
        ["@babel/plugin-proposal-private-property-in-object", { "loose": true }]
to the "plugins" section of your Babel config.

and

(node:3996) [DEP_WEBPACK_EXTERNALS_FUNCTION_PARAMETERS] DeprecationWarning: The externals-function should be defined like ({context, request}, cb) => { ... }
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:3996) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'startsWith' of undefined
    at handleExternals (D:\Development\Projects\testing-expo\node_modules\next\dist\build\webpack-config.js:661:33)
    at webpackConfig.externals (D:\Development\Projects\testing-expo\node_modules\next\dist\build\webpack-config.js:766:24)
    at D:\Development\Projects\testing-expo\node_modules\@expo\webpack-config\webpack\addons\withUnimodules.js:162:58
    at D:\Development\Projects\testing-expo\node_modules\next\dist\compiled\webpack\bundle5.js:36695:21
    at deprecated (internal/util.js:96:15)
    at handleExternals (D:\Development\Projects\testing-expo\node_modules\next\dist\compiled\webpack\bundle5.js:36843:8)
    at next (D:\Development\Projects\testing-expo\node_modules\next\dist\compiled\webpack\bundle5.js:36821:9)
    at handleExternals (D:\Development\Projects\testing-expo\node_modules\next\dist\compiled\webpack\bundle5.js:36826:7)
    at D:\Development\Projects\testing-expo\node_modules\next\dist\compiled\webpack\bundle5.js:36923:5
    at Hook.eval [as callAsync] (eval at create (D:\Development\Projects\testing-expo\node_modules\next\dist\compiled\webpack\bundle5.js:140346:10), <anonymous>:37:1)
(node:3996) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 3)
(node:3996) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:3996) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'startsWith' of undefined
    at handleExternals (D:\Development\Projects\testing-expo\node_modules\next\dist\build\webpack-config.js:661:33)
    at webpackConfig.externals (D:\Development\Projects\testing-expo\node_modules\next\dist\build\webpack-config.js:766:24)
    at D:\Development\Projects\testing-expo\node_modules\@expo\webpack-config\webpack\addons\withUnimodules.js:162:58
    at D:\Development\Projects\testing-expo\node_modules\next\dist\compiled\webpack\bundle5.js:36695:21
    at deprecated (internal/util.js:96:15)
    at handleExternals (D:\Development\Projects\testing-expo\node_modules\next\dist\compiled\webpack\bundle5.js:36843:8)
    at next (D:\Development\Projects\testing-expo\node_modules\next\dist\compiled\webpack\bundle5.js:36821:9)
    at handleExternals (D:\Development\Projects\testing-expo\node_modules\next\dist\compiled\webpack\bundle5.js:36826:7)
    at D:\Development\Projects\testing-expo\node_modules\next\dist\compiled\webpack\bundle5.js:36923:5
    at Hook.eval [as callAsync] (eval at create (D:\Development\Projects\testing-expo\node_modules\next\dist\compiled\webpack\bundle5.js:140346:10), <anonymous>:37:1)
(node:3996) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 4)
(node:3996) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'startsWith' of undefined
    at handleExternals (D:\Development\Projects\testing-expo\node_modules\next\dist\build\webpack-config.js:661:33)
    at webpackConfig.externals (D:\Development\Projects\testing-expo\node_modules\next\dist\build\webpack-config.js:766:24)
    at D:\Development\Projects\testing-expo\node_modules\@expo\webpack-config\webpack\addons\withUnimodules.js:162:58
    at D:\Development\Projects\testing-expo\node_modules\next\dist\compiled\webpack\bundle5.js:36695:21
    at deprecated (internal/util.js:96:15)
    at handleExternals (D:\Development\Projects\testing-expo\node_modules\next\dist\compiled\webpack\bundle5.js:36843:8)
    at next (D:\Development\Projects\testing-expo\node_modules\next\dist\compiled\webpack\bundle5.js:36821:9)
    at handleExternals (D:\Development\Projects\testing-expo\node_modules\next\dist\compiled\webpack\bundle5.js:36826:7)
    at D:\Development\Projects\testing-expo\node_modules\next\dist\compiled\webpack\bundle5.js:36923:5
    at Hook.eval [as callAsync] (eval at create (D:\Development\Projects\testing-expo\node_modules\next\dist\compiled\webpack\bundle5.js:140346:10), <anonymous>:37:1)
(node:3996) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 5)

I added the following line to my babel.config.js to silence the "loose" errors我将以下行添加到我的babel.config.js以消除“松散”错误

  plugins: [["@babel/plugin-proposal-private-methods", { "loose": true }]]

...but the localhost:3000 still doesn't load for me either ...但是localhost:3000仍然没有为我加载

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM