NextJS Lerna项目

时间:2019-06-11 03:54:57

标签: next.js lerna react-native-web

我有一个Lerna项目,我试图将shared文件夹中的react-native-web组件共享到我的NextJS web文件夹中。结构如下:

lerna.json
package.json
packages
    shared
        components
        package.json
    web
        pages
        next.config.js
        package.json

当我进入web并运行npm run dev时,出现以下错误:

Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.

 static async getInitialProps ({ renderPage }) {
  16 |   AppRegistry.registerComponent('Main', () => Main)
  17 |   const { getStyleElement } = AppRegistry.getApplication('Main')
> 18 |   const page = renderPage()
     | ^  19 |   const styles = [
  20 |     <style dangerouslySetInnerHTML={{ __html: normalizeNextElements }} />,
  21 |     getStyleElement()

我的next.config.js包含:

const withTM = require('next-transpile-modules')

module.exports = withTM({
    transpileModules: ['@my-proj/shared'],
    webpack: config => {
      // Alias all `react-native` imports to `react-native-web`
      config.resolve.alias = {
        ...(config.resolve.alias || {}),
        'react-native$': 'react-native-web'
      }
      return config;
    }
})

关于导致该错误的原因有什么想法?

0 个答案:

没有答案