当我尝试使用无服务器框架将我的NextJS应用程序部署到AWS时。
在Next.js应用程序目录中,我运行了命令npxserverless
并得到以下错误-
$ npx serverless
error:
Error: Command failed with exit code 1: node_modules/.bin/next build
warn - Invalid next.config.js options detected:
- The root value has an unexpected property, target, 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).
See more info here: https://nextjs.org/docs/messages/invalid-next-config
warn - The `target` config is deprecated and will be removed in a future version.
See more info here https://nextjs.org/docs/messages/deprecated-target-config
error - ESLint must be installed in order to run during builds: yarn add --dev eslint
Failed to compile.
./pages/_app.tsx:3:29
Type error: Cannot find module '@mui/material' or its corresponding type declarations.
1 | import "../styles/globals.css";
2 |
> 3 | import { CssBaseline } from "@mui/material";
| ^
4 | import { StyledEngineProvider, ThemeProvider } from "@mui/material/styles";
5 | import type { AppProps } from "next/app";
6 | import { appWithTranslation } from "next-i18next";
> Build error occurred
Error: Call retries were exceeded
at ChildProcessWorker.initialize (C:\Users\bruno.cruz\Documents\INGRESSE-COM\repo\finance-web\node_modules\next\dist\compiled\jest-worker\index.js:1:11661)
at ChildProcessWorker._onExit (C:\Users\bruno.cruz\Documents\INGRESSE-COM\repo\finance-web\node_modules\next\dist\compiled\jest-worker\index.js:1:12599)
at ChildProcess.emit (events.js:315:20)
at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12) {
type: 'WorkerError'
}
info - Loaded env from C:\Users\bruno.cruz\Documents\INGRESSE-COM\repo\finance-web\.env
info - SWC minify release candidate enabled. https://nextjs.link/swcmin
info - Linting and checking validity of types...
at makeError (C:\Users\bruno.cruz\.serverless\components\registry\npm\@sls-next\serverless-component@1.18.0\node_modules\@sls-next\serverless-component\node_modules\execa\lib\error.js:59:11)
at handlePromise (C:\Users\bruno.cruz\.serverless\components\registry\npm\@sls-next\serverless-component@1.18.0\node_modules\@sls-next\serverless-component\node_modules\execa\index.js:114:26)
at processTicksAndRejections (internal/process/task_queues.js:93:5) {
shortMessage: 'Command failed with exit code 1: node_modules/.bin/next build',
command: 'node_modules/.bin/next build',
exitCode: 1,
signal: undefined,
signalDescription: undefined,
stdout: 'info - Loaded env from C:\\Users\\bruno.cruz\\Documents\\INGRESSE-COM\\repo\\finance-web\\.env\n' +
'info - SWC minify release candidate enabled. https://nextjs.link/swcmin\n' +
'info - Linting and checking validity of types...',
stderr: 'warn - Invalid next.config.js options detected: \n' +
' - The root value has an unexpected property, target, 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).\n' +
'\n' +
'See more info here: https://nextjs.org/docs/messages/invalid-next-config\n' +
'warn - The `target` config is deprecated and will be removed in a future version.\n' +
'See more info here https://nextjs.org/docs/messages/deprecated-target-config\n' +
'error - ESLint must be installed in order to run during builds: yarn add --dev eslint\n' +
'Failed to compile.\n' +
'\n' +
'./pages/_app.tsx:3:29\n' +
"Type error: Cannot find module '@mui/material' or its corresponding type declarations.\n" +
'\n' +
'\x1B[0m \x1B[90m 1 | \x1B[39m\x1B[36mimport\x1B[39m \x1B[32m"../styles/globals.css"\x1B[39m\x1B[33m;\x1B[39m\x1B[0m\n' +
'\x1B[0m \x1B[90m 2 | \x1B[39m\x1B[0m\n' +
'\x1B[0m\x1B[31m\x1B[1m>\x1B[22m\x1B[39m\x1B[90m 3 | \x1B[39m\x1B[36mimport\x1B[39m { \x1B[33mCssBaseline\x1B[39m } \x1B[36mfrom\x1B[39m \x1B[32m"@mui/material"\x1B[39m\x1B[33m;\x1B[39m\x1B[0m\n' +
'\x1B[0m \x1B[90m | \x1B[39m \x1B[31m\x1B[1m^\x1B[22m\x1B[39m\x1B[0m\n' +
'\x1B[0m \x1B[90m 4 | \x1B[39m\x1B[36mimport\x1B[39m { \x1B[33mStyledEngineProvider\x1B[39m\x1B[33m,\x1B[39m \x1B[33mThemeProvider\x1B[39m } \x1B[36mfrom\x1B[39m \x1B[32m"@mui/material/styles"\x1B[39m\x1B[33m;\x1B[39m\x1B[0m\n' +
'\x1B[0m \x1B[90m 5 | \x1B[39m\x1B[36mimport\x1B[39m type { \x1B[33mAppProps\x1B[39m } \x1B[36mfrom\x1B[39m \x1B[32m"next/app"\x1B[39m\x1B[33m;\x1B[39m\x1B[0m\n' +
'\x1B[0m \x1B[90m 6 | \x1B[39m\x1B[36mimport\x1B[39m { appWithTranslation } \x1B[36mfrom\x1B[39m \x1B[32m"next-i18next"\x1B[39m\x1B[33m;\x1B[39m\x1B[0m\n' +
'\n' +
'> Build error occurred\n' +
'Error: Call retries were exceeded\n' +
' at ChildProcessWorker.initialize (C:\\Users\\bruno.cruz\\Documents\\INGRESSE-COM\\repo\\finance-web\\node_modules\\next\\dist\\compiled\\jest-worker\\index.js:1:11661)\n' +
' at ChildProcessWorker._onExit (C:\\Users\\bruno.cruz\\Documents\\INGRESSE-COM\\repo\\finance-web\\node_modules\\next\\dist\\compiled\\jest-worker\\index.js:1:12599)\n' +
' at ChildProcess.emit (events.js:315:20)\n' +
' at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12) {\n' +
" type: 'WorkerError'\n" +
'}',
failed: true,
timedOut: false,
isCanceled: false,
killed: false
}
11s » financeWebFront » Error: Command failed with exit code 1: node_modules/.bin/next build
warn - Invalid next.config.js options detected:
- The root value has an unexpected property, target, 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).
See more info here: https://nextjs.org/docs/messages/invalid-next-config
warn - The `target` config is deprecated and will be removed in a future version.
See more info here https://nextjs.org/docs/messages/deprecated-target-config
error - ESLint must be installed in order to run during builds: yarn add --dev eslint
Failed to compile.
./pages/_app.tsx:3:29
Type error: Cannot find module '@mui/material' or its corresponding type declarations.
1 | import "../styles/globals.css";
2 |
> 3 | import { CssBaseline } from "@mui/material";
| ^
4 | import { StyledEngineProvider, ThemeProvider } from "@mui/material/styles";
5 | import type { AppProps } from "next/app";
6 | import { appWithTranslation } from "next-i18next";
> Build error occurred
Error: Call retries were exceeded
at ChildProcessWorker.initialize (C:\Users\bruno.cruz\Documents\INGRESSE-COM\repo\finance-web\node_modules\next\dist\compiled\jest-worker\index.js:1:11661)
at ChildProcessWorker._onExit (C:\Users\bruno.cruz\Documents\INGRESSE-COM\repo\finance-web\node_modules\next\dist\compiled\jest-worker\index.js:1:12599)
at ChildProcess.emit (events.js:315:20)
at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12) {
type: 'WorkerError'
}
info - Loaded env from C:\Users\bruno.cruz\Documents\INGRESSE-COM\repo\finance-web\.env
info - SWC minify release candidate enabled. https://nextjs.link/swcmin
info - Linting and checking validity of types...
我正在使用aws configure来设置我的AWS凭据。
我的无服务器.yml文件如下所示,
myNextApplication:
component: "@sls-next/serverless-component@1.18.0"
我应该如何使用无服务器框架将我的应用部署到AWS云?
- 谢谢-谢谢
2条答案
按热度按时间o8x7eapl1#
您需要安装缺少的依赖项
npm i @mui/material
或yarn add @mui/material
。这样应该可以修复它。另外,检查您的next.config.js
文件。似乎您在那里添加了一些不属于它的内容。更重要的是,要部署到AWS,只需使用AWS Amplify。阅读文档,了解如何使用Next.js进行设置。这非常简单。只需将代码部署到github,通过Amplify连接到repo,然后让它为您构建项目。
i7uaboj42#
基本上,无服务器的nextjs已经死了,最新的版本也不受支持。
如果AWS lambda是您的唯一选项,请尝试将nextjs版本恢复到11.x