无法加载 next.config.js - TypeError:无效的主机定义选项

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

发生了什么事?

我尝试使用 antd design 运行我的 nextapp,它说较少需要加载程序,然后我发现了这个 https://github.com/SolidZORO/next-plugin-antd-less 和这个https://github.com/elado/next-with-less。还是没有成功

> cross-env NODE_OPTIONS="-r esm" next -p 3333

ready - started server on 0.0.0.0:3333, url: http://localhost:3333
error - Failed to load next.config.js, see more info here https://nextjs.org/docs/messages/next-config-error
TypeError: Invalid host defined options
    at Object.loadConfig [as default] (C:...\node_modules\next\dist\server\config.js:70:78)
    at async NextServer.loadConfig (C:...\node_modules\next\dist\server\next.js:114:22)
    at async NextServer.prepare (C:...\node_modules\next\dist\server\next.js:96:24)
    at async C:...\node_modules\next\dist\cli\next-dev.js:127:9
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] dev: `cross-env NODE_OPTIONS="-r esm" next -p 3333`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:...\AppData\Roaming\npm-cache\_logs\2022-04-12T03_39_00_931Z-debug.log

包装:

  • 节点v12.22.0
  • NextJs v12.1.4
  • 反应v17.0.2

我的next.config.js

/* eslint-disable */
const withPlugins = require('next-compose-plugins');
const withAntdLess = require('next-plugin-antd-less');

const pluginAntdLess = withAntdLess({
  lessVarsFilePath: './src/styles/variables.less'
});

module.exports = withPlugins([[pluginAntdLess]], {
  webpack(config) {
    return config
  }
});
reactjs next.js less antd
2个回答
1
投票

首先我猜你需要将节点版本升级到至少 14.x


0
投票

请问这个问题已经有解决方案了吗,我也面临着同样的问题

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