Next 14 错误:next.config.js 不再支持“target”属性

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

我刚刚使用

npx create-next-app@latest
安装了一个 nextjs 项目。

当前版本

"next": "14.1.3",
"react": "^18",
"react-dom": "^18",
"sharp": "^0.33.2"

next.config.mjs

/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: true,
};

export default nextConfig;

我的项目在开发中和构建后在本地运行得非常好。

但是在使用无服务器的AWS S3存储桶上部署Nextjs应用程序时我收到以下错误:

Error: Command failed with exit code 1: node_modules/.bin/next build

> Build error occurred
Error: The "target" property is no longer supported in next.config.js.
See more info here https://nextjs.org/docs/messages/deprecated-target-config

如您所见,我的

next.config.mjs
文件上没有任何目标属性,但我仍然收到此错误。我也尝试过
output: "standalone"
但没有成功。

我可以看到人们在堆栈溢出中面临相同的错误,但大多数问题与 AWS Amplify 有关。我正在使用 AWS S3 存储桶和无服务器

注意:我在AWS S3上部署了3个Nextjs项目,使用无服务器,配置相同,该项目唯一的区别是我在这里使用Next版本14.1.3,其余的都是Next版本12.0.8。

我不知道这是否有帮助,但这是我的 serverless.yml 文件如下

NEXT-TEST:
  component: "@sls-next/[email protected]"  
  inputs:
    runtime:
      defaultLambda: "nodejs18.x"
      apiLambda: "nodejs18.x"
      imageLambda: "nodejs18.x"
    memory:
      defaultLambda: 4096
      apiLambda: 4096
      imageLambda: 4096
    timeout:
      defaultLambda: 30
      apiLambda: 30
      imageLambda: 30
  
    bucketRegion: XXXXX
    bucketName: XXXXXX

要部署,我使用以下命令:

npx [email protected]

我搜索并尝试了许多不同的解决方案,但没有任何对我有用。

请帮忙!

amazon-web-services amazon-s3 next.js serverless next.js13
1个回答
0
投票

您需要删除node_modules文件夹并清理npm的缓存

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