【问题标题】:Error with Next Js with Expo when compiling编译时 Next Js with Expo 出错
【发布时间】:2021-03-03 07:09:54
【问题描述】:

如果我尝试在下一个 Js 中使用 expo 组件,我会收到此错误

为了清楚,我正在使用带有下一个 js 的网络博览会,所以我希望两者共享相同的组件,据我所知这是可能的,但我收到了这个错误。

错误是:

Module parse failed: Unexpected character '' (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
(Source code omitted for this binary file)

这是 next.config.js :

// Learn more: https://github.com/expo/expo/blob/master/docs/pages/versions/unversioned/guides/using-nextjs.md#withexpo

const { withExpo } = require('@expo/next-adapter');

module.exports = withExpo({
  projectRoot: __dirname,
});

这是 babel 配置:

// Learn more: https://github.com/expo/expo/blob/master/docs/pages/versions/unversioned/guides/using-nextjs.md#shared-steps

module.exports = { presets: ['@expo/next-adapter/babel'] };

请帮助,希望信息足够

【问题讨论】:

  • 我也得到了这个

标签: reactjs react-native expo next.js


【解决方案1】:

尝试用这个替换 next.config.js (&npm install next-images next-fonts)

const { withExpo } = require('@expo/next-adapter')
const withImages = require('next-images')
const withFonts = require('next-fonts')

module.exports = withExpo(
  withImages(
    withFonts({
      projectRoot: __dirname,
    })
  )
);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-07-12
    • 2022-01-10
    • 1970-01-01
    • 1970-01-01
    • 2023-01-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多