下一个 JS 部署在 Amazon Amplify 上失败
Next JS deployment fail on Amazon Amplify
我正在尝试在 Next JS 上部署 SSG 应用程序,但它一次又一次地失败,我收到构建失败的错误消息。我已按照在亚马逊上部署 SSG 站点的文档进行操作,但仍然出现错误,我不知道出了什么问题。
下面是我的放大应用程序的日志:
2021-09-24T10:55:48.543Z [HELP]: Outputting the npm debug log
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli '/root/.nvm/versions/node/v12.21.0/bin/node',
1 verbose cli '/root/.nvm/versions/node/v12.21.0/bin/npm',
1 verbose cli 'run',
1 verbose cli 'build'
1 verbose cli ]
2 info using npm@6.14.11
3 info using node@v12.21.0
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 verbose lifecycle xyz@0.1.0~build: CWD: /codebuild/output/src168230001/src/xyz
6 silly lifecycle xyz@0.1.0~build: Args: [ '-c', 'next build && next export' ]
7 silly lifecycle xyz@0.1.0~build: Returned: code: 1 signal: null
8 info lifecycle xyz@0.1.0~build: Failed to exec build script
9 verbose stack Error: xyz@0.1.0 build: `next build && next export`
10 verbose stack Exit status 1
11 verbose stack at EventEmitter.<anonymous> (/root/.nvm/versions/node/v12.21.0/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
12 verbose stack at EventEmitter.emit (events.js:314:20)
13 verbose stack at ChildProcess.<anonymous> (/root/.nvm/versions/node/v12.21.0/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:314:20)
13 verbose stack at maybeClose (internal/child_process.js:1022:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5)
14 verbose pkgid xyz@0.1.0
15 verbose cwd /codebuild/output/src168230001/src/xyz
16 verbose Linux 4.14.238-125.422.amzn1.x86_64
17 verbose argv "/root/.nvm/versions/node/v12.21.0/bin/node" "/root/.nvm/versions/node/v12.21.0/bin/npm" "run" "build"
18 verbose node v12.21.0
19 verbose npm v6.14.11
20 error code ELIFECYCLE
21 error errno 1
22 error xyz@0.1.0 build: `next build && next export`
22 error Exit status 1
23 error Failed at the xyz@0.1.0 build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
2021-09-24T10:55:48.546Z [ERROR]: !!! Build failed
2021-09-24T10:55:48.546Z [ERROR]: !!! Non-Zero Exit Code detected
2021-09-24T10:55:48.546Z [INFO]: # Starting environment caching...
2021-09-24T10:55:48.546Z [INFO]: # Uploading environment cache artifact...
2021-09-24T10:55:48.631Z [INFO]: # Environment caching completed
Terminating logging...
问题出在图像优化上。我将脚本添加到我的 next.config.js 文件中以解决问题。
const withImages = require('next-images')
module.exports = withImages()
module.exports = withImages({
images: {
loader: "imgix",
path: "",
},
exportPathMap: async function (
defaultPathMap,
{ dev, dir, outDir, distDir, buildId }
) {
return {
'/': { page: '/' },
}
},
})
我正在尝试在 Next JS 上部署 SSG 应用程序,但它一次又一次地失败,我收到构建失败的错误消息。我已按照在亚马逊上部署 SSG 站点的文档进行操作,但仍然出现错误,我不知道出了什么问题。
下面是我的放大应用程序的日志:
2021-09-24T10:55:48.543Z [HELP]: Outputting the npm debug log
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli '/root/.nvm/versions/node/v12.21.0/bin/node',
1 verbose cli '/root/.nvm/versions/node/v12.21.0/bin/npm',
1 verbose cli 'run',
1 verbose cli 'build'
1 verbose cli ]
2 info using npm@6.14.11
3 info using node@v12.21.0
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 verbose lifecycle xyz@0.1.0~build: CWD: /codebuild/output/src168230001/src/xyz
6 silly lifecycle xyz@0.1.0~build: Args: [ '-c', 'next build && next export' ]
7 silly lifecycle xyz@0.1.0~build: Returned: code: 1 signal: null
8 info lifecycle xyz@0.1.0~build: Failed to exec build script
9 verbose stack Error: xyz@0.1.0 build: `next build && next export`
10 verbose stack Exit status 1
11 verbose stack at EventEmitter.<anonymous> (/root/.nvm/versions/node/v12.21.0/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
12 verbose stack at EventEmitter.emit (events.js:314:20)
13 verbose stack at ChildProcess.<anonymous> (/root/.nvm/versions/node/v12.21.0/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:314:20)
13 verbose stack at maybeClose (internal/child_process.js:1022:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5)
14 verbose pkgid xyz@0.1.0
15 verbose cwd /codebuild/output/src168230001/src/xyz
16 verbose Linux 4.14.238-125.422.amzn1.x86_64
17 verbose argv "/root/.nvm/versions/node/v12.21.0/bin/node" "/root/.nvm/versions/node/v12.21.0/bin/npm" "run" "build"
18 verbose node v12.21.0
19 verbose npm v6.14.11
20 error code ELIFECYCLE
21 error errno 1
22 error xyz@0.1.0 build: `next build && next export`
22 error Exit status 1
23 error Failed at the xyz@0.1.0 build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
2021-09-24T10:55:48.546Z [ERROR]: !!! Build failed
2021-09-24T10:55:48.546Z [ERROR]: !!! Non-Zero Exit Code detected
2021-09-24T10:55:48.546Z [INFO]: # Starting environment caching...
2021-09-24T10:55:48.546Z [INFO]: # Uploading environment cache artifact...
2021-09-24T10:55:48.631Z [INFO]: # Environment caching completed
Terminating logging...
问题出在图像优化上。我将脚本添加到我的 next.config.js 文件中以解决问题。
const withImages = require('next-images')
module.exports = withImages()
module.exports = withImages({
images: {
loader: "imgix",
path: "",
},
exportPathMap: async function (
defaultPathMap,
{ dev, dir, outDir, distDir, buildId }
) {
return {
'/': { page: '/' },
}
},
})