Home > database >  when hosting next js with aws ampify "Failed to set up process.env.secrets"
when hosting next js with aws ampify "Failed to set up process.env.secrets"

Time:10-02

hi i am trying to host web/app with AWS Amplify. but it keeps don't working.

i start the code with yarn so i already removed package.lock.json and input in the console this code: moment prop-types typescript

Here is the error code:

2022-10-01T05:02:39.118Z [INFO]: # Cloning repository: [email protected]:arty0928/SNS-Community-Instagram.git
2022-10-01T05:02:41.683Z [INFO]: Cloning into 'SNS-Community-Instagram'...
2022-10-01T05:02:41.683Z [INFO]: # Switching to commit: fcdeed8e4d4542a5fd5550c9d7f795f0b9c39e96
2022-10-01T05:02:41.691Z [INFO]: Note: switching to 'fcdeed8e4d4542a5fd5550c9d7f795f0b9c39e96'.
                                 You are in 'detached HEAD' state. You can look around, make experimental
                                 changes and commit them, and you can discard any commits you make in this
                                 state without impacting any branches by switching back to a branch.
                                 If you want to create a new branch to retain commits you create, you may
                                 do so (now or later) by using -c with the switch command. Example:
                                 git switch -c <new-branch-name>
                                 Or undo this operation with:
                                 git switch -
                                 Turn off this advice by setting config variable advice.detachedHead to false
                                 HEAD is now at fcdeed8 1001
2022-10-01T05:02:41.756Z [INFO]: Successfully cleaned up Git credentials
2022-10-01T05:02:41.756Z [INFO]: # Checking for Git submodules at: /codebuild/output/src195284664/src/SNS-Community-Instagram/.gitmodules
2022-10-01T05:02:41.782Z [INFO]: # Retrieving environment cache...
2022-10-01T05:02:42.530Z [INFO]: # Retrieved environment cache
2022-10-01T05:02:42.626Z [INFO]: ---- Setting Up SSM Secrets ----
2022-10-01T05:02:42.626Z [INFO]: SSM params {"Path":"/amplify/d2pnqm4mqnrup0/main/","WithDecryption":true}
2022-10-01T05:02:42.654Z [WARNING]: !Failed to set up process.env.secrets
2022-10-01T05:02:42.672Z [INFO]: No live updates for this build run
2022-10-01T05:02:42.676Z [INFO]: # Retrieving cache...
2022-10-01T05:02:42.720Z [INFO]: # Extracting cache...
2022-10-01T05:02:42.727Z [INFO]: # Extraction completed
2022-10-01T05:03:42.529Z [INFO]: ## Starting Backend Build
                                 ## Checking for associated backend environment...
                                 ## No backend environment association found, continuing...
                                 ## Completed Backend Build
2022-10-01T05:03:42.531Z [INFO]: {"backendDuration": 0}
                                 ## Starting Frontend Build
                                 # Starting phase: preBuild
                                 # Executing command: yarn install
2022-10-01T05:03:43.320Z [INFO]: yarn install v1.22.0
2022-10-01T05:03:43.407Z [INFO]: [1/4] Resolving packages...
2022-10-01T05:03:45.776Z [INFO]: [2/4] Fetching packages...
2022-10-01T05:04:04.328Z [INFO]: info @next/[email protected]: The platform "linux" is incompatible with this module.
                                 info "@next/[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
2022-10-01T05:04:04.329Z [INFO]: info @next/[email protected]: The platform "linux" is incompatible with this module.
                                 info "@next/[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
                                 info @next/[email protected]: The CPU architecture "x64" is incompatible with this module.
                                 info @next/[email protected]: The platform "linux" is incompatible with this module.
                                 info "@next/[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
                                 info @next/[email protected]: The platform "linux" is incompatible with this module.
                                 info "@next/[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
                                 info @next/[email protected]: The CPU architecture "x64" is incompatible with this module.
                                 info @next/[email protected]: The CPU architecture "x64" is incompatible with this module.
                                 info "@next/[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
                                 info @next/[email protected]: The platform "linux" is incompatible with this module.
                                 info "@next/[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
                                 info @next/[email protected]: The CPU architecture "x64" is incompatible with this module.
                                 info "@next/[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
                                 info @next/[email protected]: The platform "linux" is incompatible with this module.
                                 info "@next/[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
                                 info @next/[email protected]: The CPU architecture "x64" is incompatible with this module.
                                 info @next/[email protected]: The platform "linux" is incompatible with this module.
                                 info "@next/[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
                                 info @next/[email protected]: The CPU architecture "x64" is incompatible with this module.
                                 info @next/[email protected]: The platform "linux" is incompatible with this module.
                                 info "@next/[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
                                 info @next/[email protected]: The CPU architecture "x64" is incompatible with this module.
                                 info @next/[email protected]: The CPU architecture "x64" is incompatible with this module.
                                 info "@next/[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
2022-10-01T05:04:04.332Z [INFO]: info [email protected]: The platform "linux" is incompatible with this module.
2022-10-01T05:04:04.332Z [INFO]: info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
2022-10-01T05:04:04.333Z [INFO]: [3/4] Linking dependencies...
2022-10-01T05:04:09.240Z [INFO]: [4/4] Building fresh packages...
2022-10-01T05:04:09.563Z [INFO]: success Saved lockfile.
2022-10-01T05:04:09.566Z [INFO]: Done in 26.25s.
2022-10-01T05:04:09.587Z [INFO]: # Completed phase: preBuild
                                 # Starting phase: build
2022-10-01T05:04:09.588Z [INFO]: # Executing command: yarn run build
2022-10-01T05:04:09.706Z [INFO]: yarn run v1.22.0
2022-10-01T05:04:09.732Z [INFO]: $ next build && next export
2022-10-01T05:04:10.101Z [WARNING]: warn  - Invalid next.config.js options detected:
2022-10-01T05:04:10.102Z [WARNING]: - The root value has an unexpected property, mode, 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).
2022-10-01T05:04:10.102Z [WARNING]: - The root value has an unexpected property, theme, 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).
                                    - The root value has an unexpected property, variants, 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).
                                    - The root value has an unexpected property, plugins, 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
2022-10-01T05:04:10.105Z [INFO]: warn  - No build cache found. Please configure build caching for faster rebuilds. Read more: https://nextjs.org/docs/messages/no-cache
2022-10-01T05:04:10.147Z [INFO]: Attention: Next.js now collects completely anonymous telemetry regarding usage.
2022-10-01T05:04:10.147Z [INFO]: This information is used to shape Next.js' roadmap and prioritize features.
                                 You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
                                 https://nextjs.org/telemetry
2022-10-01T05:04:10.236Z [INFO]: info  - Linting and checking validity of types...
2022-10-01T05:04:12.264Z [INFO]: info  - Creating an optimized production build...
2022-10-01T05:04:41.658Z [INFO]: info  - Compiled successfully
2022-10-01T05:04:41.659Z [INFO]: info  - Collecting page data...
2022-10-01T05:04:46.213Z [INFO]: info  - Generating static pages (0/10)
2022-10-01T05:04:46.256Z [INFO]: info  - Generating static pages (2/10)
2022-10-01T05:04:46.264Z [INFO]: info  - Generating static pages (4/10)
2022-10-01T05:04:46.275Z [INFO]: info  - Generating static pages (7/10)
2022-10-01T05:04:46.282Z [INFO]: info  - Generating static pages (10/10)
2022-10-01T05:04:46.296Z [INFO]: info  - Finalizing page optimization...
2022-10-01T05:04:46.301Z [INFO]: 
2022-10-01T05:04:46.318Z [INFO]: Route (pages)                              Size     First Load JS
                                 ┌ ○ /                                      212 B          1.22 MB
                                 ├   /_app                                  0 B             110 kB
                                 ├ ○ /404                                   194 B           110 kB
                                 ├ λ /api/auth/[...nextauth]                0 B             110 kB
                                 ├ λ /api/hello                             0 B             110 kB
                                 ├ ○ /auth/Exercise                         3.19 kB        1.22 MB
                                 ├ ○ /auth/Hobby                            3.18 kB        1.22 MB
                                 ├ ○ /auth/Introduce                        396 B          1.22 MB
                                 ├ ○ /auth/Invest                           3.19 kB        1.22 MB
                                 ├ ○ /auth/News                             3.18 kB        1.22 MB
                                 ├ ○ /auth/Reading                          3.19 kB        1.22 MB
                                 ├ λ /auth/signin                           664 B          1.22 MB
                                 └ ○ /auth/Study                            3.18 kB        1.22 MB
                                   First Load JS shared by all              115 kB
                                 ├ chunks/framework-4556c45dd113b893.js   45.2 kB
                                 ├ chunks/main-153ca532c98eee0d.js        31.1 kB
                                 ├ chunks/pages/_app-c5a4783636926992.js  32.7 kB
                                 ├ chunks/webpack-cb7634a8b6194820.js     884 B
                                 └ css/9331222e262f4b1a.css               5.25 kB
2022-10-01T05:04:46.319Z [INFO]: λ  (Server)  server-side renders at runtime (uses getInitialProps or getServerSideProps)
                                 ○  (Static)  automatically rendered as static HTML (uses no initial props)
2022-10-01T05:04:46.776Z [WARNING]: warn  - Invalid next.config.js options detected:
2022-10-01T05:04:46.778Z [WARNING]: - The root value has an unexpected property, mode, 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).
2022-10-01T05:04:46.778Z [WARNING]: - The root value has an unexpected property, theme, 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).
                                    - The root value has an unexpected property, variants, 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).
                                    - The root value has an unexpected property, plugins, 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
2022-10-01T05:04:46.881Z [INFO]: info  - using build directory: /codebuild/output/src195284664/src/SNS-Community-Instagram/.next
2022-10-01T05:04:46.884Z [INFO]: info  - Copying "static build" directory
2022-10-01T05:04:46.887Z [INFO]: info  - No "exportPathMap" found in "/codebuild/output/src195284664/src/SNS-Community-Instagram/next.config.js". Generating map from "./pages"
2022-10-01T05:04:46.889Z [WARNING]: Error: Image Optimization using Next.js' default loader is not compatible with `next export`.
                                    Possible solutions:
                                    - Use `next start` to run a server, which includes the Image Optimization API.
                                    - Configure `images.unoptimized = true` in `next.config.js` to disable the Image Optimization API.
                                    Read more: https://nextjs.org/docs/messages/export-image-api
                                    at /codebuild/output/src195284664/src/SNS-Community-Instagram/node_modules/next/dist/export/index.js:149:23
                                    at async Span.traceAsyncFn (/codebuild/output/src195284664/src/SNS-Community-Instagram/node_modules/next/dist/trace/trace.js:79:20)
2022-10-01T05:04:46.903Z [WARNING]: error Command failed with exit code 1.
2022-10-01T05:04:46.904Z [INFO]: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
2022-10-01T05:04:46.908Z [ERROR]: !!! Build failed
2022-10-01T05:04:46.908Z [ERROR]: !!! Non-Zero Exit Code detected
2022-10-01T05:04:46.908Z [INFO]: # Starting environment caching...
2022-10-01T05:04:46.909Z [INFO]: # Environment caching completed
Terminating logging...

This is package.json code:

{
  "name": "my-project",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build && next export",
    "start": "next start",
    "lint": "next lint",
    "netlify-deploy": "next build && next export"
  },
  "dependencies": {
    "@faker-js/faker": "^7.5.0",
    "@headlessui/react": "^1.7.2",
    "@heroicons/react": "^1.0.6",
    "@tailwindcss/forms": "^0.5.3",
    "fake": "^0.2.2",
    "faker": "^6.6.6",
    "firebase": "^9.10.0",
    "moment": "^2.29.4",
    "next": "12.3.0",
    "next-auth": "^4.10.3",
    "prop-types": "^15.8.1",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "react-moment": "^1.1.2",
    "react-router-dom": "^6.4.1",
    "recoil": "^0.7.5",
    "tailwind-scrollbar-hide": "^1.1.7",
    "typescript": "^4.8.4"
  },
  "devDependencies": {
    "autoprefixer": "^10.4.11",
    "eslint": "8.23.1",
    "eslint-config-next": "12.3.0",
    "postcss": "^8.4.16",
    "tailwind-scrollbar": "^2.0.1",
    "tailwindcss": "^3.1.8"
  }
}

how can i use these whole error? i am trying to host this for a week.. please help me out

CodePudding user response:

By reading the following amplify console logs. It's seems that you have not disabled Image Optimization feature of the Nextjs.

Error: Image Optimization using Next.js' default loader is not compatible with next export. Possible solutions:

As per the Amplify Docs

Image Optimization using Next.js' default loader is not compatible with next export. To manually deploy the next-app example, you must edit the index.js file to remove this feature following the steps below.

Next, locate the similar <Image> Tag you have used in the Project

<Image src="/vercel.svg" alt="Vercel Logo" width={72} height={16} />

Edit the tag to use the HTML img tag as follows:

<img src="/vercel.svg" alt="Vercel Logo" width={72} height={16} />

You can read further about it here

CodePudding user response:

In you next.config.js, define your loader as "akamai". If you're sourcing any images using URL and reactStrictMode is set to true, define the image URL in the domains object.

module.exports = {
  reactStrictMode: true, 
  images:{
    loader: 'akamai',
    domains: [
      "image URL",
    ]
 }

Alternatively, leave your images unoptimised.

module.exports = {
  reactStrictMode: true,       
  images:{
    unoptimized: true,
  }
  • Related