nx.dev next.config.js:意外的令牌“导出”

问题描述 投票:0回答:1

如何在nx.dev monorepo中导入next.config.js中的其他库?

我的

nx dev project-app
有错误:

Failed to process project graph. Run "nx reset" to fix this. Please report the issue if you keep seeing it. See errors below.

Failed to process project graph. Run "nx reset" to fix this. Please report the issue if you keep seeing it.
  AggregateCreateNodesError: An error occurred while processing files for the @nx/next/plugin plugin.
    - apps/project-app/next.config.js: Unexpected token 'export'

我创建空的 next.js 模板并使用 nx.dev 创建默认的 js 库

应用程序/项目应用程序/next.config.js

//@ts-check

// eslint-disable-next-line @typescript-eslint/no-var-requires
const { composePlugins, withNx } = require('@nx/next');
const {mylib} = require('@project/mylib');

console.log(mylib())

/**
 * @type {import('@nx/next/plugins/with-nx').WithNxOptions}
 **/
const nextConfig = {
  nx: {
    // Set this to true if you would like to use SVGR
    // See: https://github.com/gregberge/svgr
    svgr: false,
  },
};

const plugins = [
  // Add more Next.js plugins to this list if needed.
  withNx,
];

module.exports = composePlugins(...plugins)(nextConfig);

mylib/src/index.ts

export function mylib(): string {
  return 'mylib';
}
javascript next.js nx.dev
1个回答
0
投票
const composePluginsConfig = composePlugins(...plugins)(nextConfig);
module.exports = composePluginsConfig

尝试使用上面的语法

© www.soinside.com 2019 - 2024. All rights reserved.