如何使react native paper与next.js一起工作?
我安装了这个示例,并在其中添加了react native paper,每当我使用它时,都会出现此错误如何使react native paper与next.js一起工作?,next.js,react-native-web,react-native-paper,Next.js,React Native Web,React Native Paper,我安装了这个示例,并在其中添加了react native paper,每当我使用它时,都会出现此错误 Error: Cannot find module 'react-native' Require stack: - /Users/amesbahi/Code/with-react-native-web-app/node_modules/react-native-paper/lib/commonjs/styles/fonts.js - /Users/amesbahi/Code/with-react
Error: Cannot find module 'react-native'
Require stack:
- /Users/amesbahi/Code/with-react-native-web-app/node_modules/react-native-paper/lib/commonjs/styles/fonts.js
- /Users/amesbahi/Code/with-react-native-web-app/node_modules/react-native-paper/lib/commonjs/styles/DefaultTheme.js
- /Users/amesbahi/Code/with-react-native-web-app/node_modules/react-native-paper/lib/commonjs/core/theming.js
- /Users/amesbahi/Code/with-react-native-web-app/node_modules/react-native-paper/lib/commonjs/index.js
- /Users/amesbahi/Code/with-react-native-web-app/.next/server/static/development/pages/index.js
- /Users/amesbahi/Code/with-react-native-web-app/node_modules/next/dist/next-server/server/require.js
- /Users/amesbahi/Code/with-react-native-web-app/node_modules/next/dist/next-server/server/load-components.js
- /Users/amesbahi/Code/with-react-native-web-app/node_modules/next/dist/next-server/server/api-utils.js
- /Users/amesbahi/Code/with-react-native-web-app/node_modules/next/dist/next-server/server/next-server.js
- /Users/amesbahi/Code/with-react-native-web-app/node_modules/next/dist/server/next.js
- /Users/amesbahi/Code/with-react-native-web-app/node_modules/next/dist/server/lib/start-server.js
- /Users/amesbahi/Code/with-react-native-web-app/node_modules/next/dist/cli/next-dev.js
- /Users/amesbahi/Code/with-react-native-web-app/node_modules/next/dist/bin/next
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:954:17)
at Function.Module._load (internal/modules/cjs/loader.js:847:27)
at Module.require (internal/modules/cjs/loader.js:1016:19)
at require (internal/modules/cjs/helpers.js:69:18)
at Object.<anonymous> (/Users/amesbahi/Code/with-react-native-web-app/node_modules/react-native-paper/lib/commonjs/styles/fonts.js:1:279)
at Module._compile (internal/modules/cjs/loader.js:1121:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1160:10)
at Module.load (internal/modules/cjs/loader.js:976:32)
at Function.Module._load (internal/modules/cjs/loader.js:884:14)
at Module.require (internal/modules/cjs/loader.js:1016:19)
at require (internal/modules/cjs/helpers.js:69:18)
at Object.<anonymous> (/Users/amesbahi/Code/with-react-native-web-app/node_modules/react-native-paper/lib/commonjs/styles/DefaultTheme.js:1:282)
at Module._compile (internal/modules/cjs/loader.js:1121:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1160:10)
at Module.load (internal/modules/cjs/loader.js:976:32)
at Function.Module._load (internal/modules/cjs/loader.js:884:14)
错误:找不到模块'react native'
需要堆栈:
-/Users/amesbahi/Code/with react native web app/node_modules/react native paper/lib/commonjs/styles/fonts.js
-/Users/amesbahi/Code/with react native web app/node_modules/react native paper/lib/commonjs/styles/DefaultTheme.js
-/Users/amesbahi/Code/with react native web app/node_modules/react native paper/lib/commonjs/core/theming.js
-/Users/amesbahi/Code/with react native web app/node_modules/react native paper/lib/commonjs/index.js
-/Users/amesbahi/Code/with react native web app/.next/server/static/development/pages/index.js
-/Users/amesbahi/Code/with react native web app/node_modules/next/dist/next server/server/require.js
-/Users/amesbahi/Code/with react native web app/node_modules/next/dist/next server/server/load-components.js
-/Users/amesbahi/Code/with react native web app/node_modules/next/dist/next server/server/api-utils.js
-/Users/amesbahi/Code/with react native web app/node_modules/next/dist/next server/server/next-server.js
-/Users/amesbahi/Code/with react native web app/node_modules/next/dist/server/next.js
-/Users/amesbahi/Code/with react native web app/node_modules/next/dist/server/lib/start-server.js
-/Users/amesbahi/Code/with react native web app/node_modules/next/dist/cli/next-dev.js
-/Users/amesbahi/Code/with react native web app/node_modules/next/dist/bin/next
位于Function.Module.\u resolveFilename(internal/modules/cjs/loader.js:954:17)
at Function.Module._load(内部/modules/cjs/loader.js:847:27)
at Module.require(内部/modules/cjs/loader.js:1016:19)
根据需要(内部/modules/cjs/helpers.js:69:18)
反对
我已经为此挣扎了几天了。希望有人能帮助我我和你有同样的方法和问题。
下面是我如何在Next.js中编写React原生文件的
构建Next.js并使用Expo.io响应本机Web(RNW)
检查并确保它在本地计算机上运行
遵循部分,在React Native Paper文档中,但是,关于next.config.js
,您只需要这样做
由于Expo已经提供了这些内置插件来加载图像和字体,您不需要手动为您的网页添加任何加载程序,只要使用它,它就会工作。因此我们可以跳过CRA
,自定义网页设置
和配置网页
?
const { withExpo } = require("@expo/next-adapter");
const withImages = require("next-images");
const withFonts = require("next-fonts");
module.exports = withExpo(
withFonts(
withImages({
projectRoot: __dirname
})
)
);