webpack 警告:运行项目时next.config.js无效- nextJs

czq61nw1  于 2022-11-13  发布在  Webpack
关注(0)|答案(1)|浏览(543)

当我想运行我的项目时,我有以下三个警告:

1-
warn  - Invalid next.config.js options detected:  The root value has an unexpected property, webpack5, which is not in the list of allowed properties (amp, analyticsId, assetPrefix, basePath, cleanDistDir, compiler, compress, crossOrigin, devIndicators, distDir, env, eslint, excludeDefaultMomentLocales, experimental, exportPathMap, future, generateBuildId, generateEtags, headers, httpAgentOptions, i18n, images, onDemandEntries, optimizeFonts, output, outputFileTracing, pageExtensions, poweredByHeader, productionBrowserSourceMaps, publicRuntimeConfig, reactStrictMode, redirects, rewrites, sassOptions, serverRuntimeConfig, staticPageGenerationTimeout, swcMinify, trailingSlash, typescript, useFileSystemPublicRoutes, webpack).

2-
warn  - Fast Refresh had to perform a full reload. Read more: https://nextjs.org/docs/basic-features/fast-refresh#how-it-works

3-
warn  - ./node_modules/next-i18next/dist/commonjs/serverSideTranslations.js
Critical dependency: the request of a dependency is an expression

这是我的next.config.js

const {i18n} = require('./next-i18next.config')
const withVideos = require('next-videos')
module.exports = withVideos({
  reactStrictMode : true,
  i18n,
  webpack5: true,
  webpack: (config) => {
    config.resolve.fallback = { fs: false };

    return config;
  },
})

我甚至试过这个:

/**
 * @type {import('next').NextConfig}
 */
 const {i18n} = require('./next-i18next.config')
 const withVideos = require('next-videos')

 const nextConfig = {
  reactStrictMode : true,
  i18n,
  webpack5: true,
  webpack: (config) => {
    config.resolve.fallback = { fs: false };

    return config;
  },
}

module.exports = withVideos(nextConfig)

结果相同。

j9per5c4

j9per5c41#

我不知道这是否有用,但我希望如此。
我在使用Google的“自动完成”功能时遇到了同样的问题:
根值具有意外属性autoComplete,该属性不在允许的属性列表中(amp,...
我将它 Package 成一个“env”对象,如下所示:

const nextConfig = {
  ...
  i18n: {
    ...
  },
  env: {
    ...
    autoComplete: {
      publicApiKey: '...',
    },
  },
  ...
}

重新启动我的应用程序后,警告就消失了。

相关问题