我目前正在尝试在 AWS Amplify 上托管我的 next.js 应用程序,但每次都失败。我正在使用 Git CI/CD 管道。当在 Vercel 上部署相同的应用程序时,它仅在 60 秒内就完成了部署,并且可以正常工作。这是我得到的错误:
Starting SSR Build...
2021-07-15T17:21:36.050Z [ERROR]: Error: '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: 'Failed to compile.\n' +
'\n' +
"ModuleNotFoundError: Module not found: Error: Can't resolve 'mock-aws-s3' in '/<project_location>/node_modules/@mapbox/node-pre-gyp/lib/util'\n" +
'\n' +
'\n' +
'> Build error occurred\n' +
'Error: > Build failed because of webpack errors\n' +
' at /<project_location>/node_modules/next/dist/build/index.js:15:924\n' +
' at async Span.traceAsyncFn (/<project_location>/node_modules/next/dist/telemetry/trace/trace.js:6:584)',
failed: true,
timedOut: false,
isCanceled: false,
Terminating logging...
编辑: 这是 package.json 文件
{
"name": "laturnaorders",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"axios": "^0.21.1",
"bcrypt": "^5.0.1",
"bootstrap": "5.0.2",
"jsonwebtoken": "^8.5.1",
"mongoose": "^5.13.2",
"next": "11.0.1",
"next-connect": "^0.10.1",
"react": "17.0.2",
"react-bootstrap": "^2.0.0-beta.2",
"react-dom": "17.0.2",
"react-select": "^4.3.1",
"sass": "^1.35.2"
},
"devDependencies": {
"eslint": "7.30.0",
"eslint-config-next": "11.0.1"
}
}
编辑 2:
我查了一下,它似乎mock-aws-s3
是包的 devDependency @mapbox/node-pre-gyp
,它本身是bcrypt.js
. 这与节点版本有关吗?我目前正在使用node v16.4.0