我正在尝试将我的 next.js 应用程序部署到 aws Amplify 中,但每次尝试部署它时我都会遇到相同的错误。我已经能够部署该应用程序两次,但是当我第三次尝试更新它时,控制台向我抛出了此消息:
2021-08-24T21:03:47.297Z [INFO]: Starting SSR Build...
2021-08-24T21:04:41.460Z [ERROR]: Error: Command failed with exit code 1: node_modules/.bin/next build
warn - No ESLint configuration detected. Run next lint to begin setup
Failed to compile.
ModuleNotFoundError: Module not found: Error: Can't resolve 'mock-aws-s3' in '/codebuild/output/src724308348/src/proyect-live/node_modules/@mapbox/node-pre-gyp/lib/util'
> Build error occurred
Error: > Build failed because of webpack errors
at /codebuild/output/src724308348/src/proyect-live/node_modules/next/dist/build/index.js:15:924
at async Span.traceAsyncFn (/codebuild/output/src724308348/src/proyect-live/node_modules/next/dist/telemetry/trace/trace.js:6:584)
info - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
info - Checking validity of types...
info - Creating an optimized production build...
at makeError (/root/.//node_modules/execa/lib/error.js:59:11)
at handlePromise (/root/.//node_modules/execa/index.js:114:26)
at processTicksAndRejections (internal/process/task_queues.js:97: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 - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5\n' +
'info - Checking validity of types...\n' +
'info - Creating an optimized production build...',
stderr: 'warn - No ESLint configuration detected. Run next lint to begin setup\n' +
'Failed to compile.\n' +
'\n' +
"ModuleNotFoundError: Module not found: Error: Can't resolve 'mock-aws-s3' in '/codebuild/output/src724308348/src/proyect-live/node_modules/@mapbox/node-pre-gyp/lib/util'\n" +
'\n' +
'\n' +
'> Build error occurred\n' +
'Error: > Build failed because of webpack errors\n' +
我的 package.json 看起来像这样:
{
"name": "proyect-nextjs",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start"
},
"dependencies": {
"@material-ui/core": "^4.12.3",
"@material-ui/icons": "^4.11.2",
"@material-ui/lab": "^4.0.0-alpha.60",
"bcrypt": "^5.0.1",
"mongoose": "^5.13.7",
"next": "^11.0.0",
"next-auth": "^3.29.0",
"react": "^17.0.2",
"react-dom": "^17.0.2"
},
"devDependencies": {}
}
我在消息中看到“未找到”模块 mock-aws-s3,但我从未在任何地方使用过此模块,也不知道它来自何处。
有没有其他人遇到过这个问题或知道可能导致问题的原因?