【发布时间】:2020-05-15 11:21:43
【问题描述】:
我有一个带有 monorepo 设置的简单项目。当我尝试在 web next js project 中使用/导入shared module 时,出现以下错误
【问题讨论】:
标签: reactjs react-native next.js monorepo yarn-workspaces
我有一个带有 monorepo 设置的简单项目。当我尝试在 web next js project 中使用/导入shared module 时,出现以下错误
【问题讨论】:
标签: reactjs react-native next.js monorepo yarn-workspaces
默认情况下,Next.js 不会在 node_modules / 主文件夹外部编译/转换模块,因此在运行时会出现流语法异常。
我使用next-transpile-modules 来转译特定模块。
// next.config.js
const withTM = require('next-transpile-modules')(['shared-ui', 'other-shared-lib']);
modules.exports = withTM({
...regular next config
});
【讨论】: