This question already has answers here:
Error: Image Optimization using Next.js default loader is not compatible with `next export`
(5 answers)
Closed 4 months ago.
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: git#github.com: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/swc-win32-x64-msvc#12.3.0: The platform "linux" is incompatible with this module.
info "#next/swc-win32-x64-msvc#12.3.0" is an optional dependency and failed compatibility check. Excluding it from installation.
2022-10-01T05:04:04.329Z [INFO]: info #next/swc-android-arm64#12.3.0: The platform "linux" is incompatible with this module.
info "#next/swc-android-arm64#12.3.0" is an optional dependency and failed compatibility check. Excluding it from installation.
info #next/swc-android-arm64#12.3.0: The CPU architecture "x64" is incompatible with this module.
info #next/swc-freebsd-x64#12.3.0: The platform "linux" is incompatible with this module.
info "#next/swc-freebsd-x64#12.3.0" is an optional dependency and failed compatibility check. Excluding it from installation.
info #next/swc-android-arm-eabi#12.3.0: The platform "linux" is incompatible with this module.
info "#next/swc-android-arm-eabi#12.3.0" is an optional dependency and failed compatibility check. Excluding it from installation.
info #next/swc-android-arm-eabi#12.3.0: The CPU architecture "x64" is incompatible with this module.
info #next/swc-linux-arm64-musl#12.3.0: The CPU architecture "x64" is incompatible with this module.
info "#next/swc-linux-arm64-musl#12.3.0" is an optional dependency and failed compatibility check. Excluding it from installation.
info #next/swc-darwin-x64#12.3.0: The platform "linux" is incompatible with this module.
info "#next/swc-darwin-x64#12.3.0" is an optional dependency and failed compatibility check. Excluding it from installation.
info #next/swc-linux-arm64-gnu#12.3.0: The CPU architecture "x64" is incompatible with this module.
info "#next/swc-linux-arm64-gnu#12.3.0" is an optional dependency and failed compatibility check. Excluding it from installation.
info #next/swc-win32-arm64-msvc#12.3.0: The platform "linux" is incompatible with this module.
info "#next/swc-win32-arm64-msvc#12.3.0" is an optional dependency and failed compatibility check. Excluding it from installation.
info #next/swc-win32-arm64-msvc#12.3.0: The CPU architecture "x64" is incompatible with this module.
info #next/swc-win32-ia32-msvc#12.3.0: The platform "linux" is incompatible with this module.
info "#next/swc-win32-ia32-msvc#12.3.0" is an optional dependency and failed compatibility check. Excluding it from installation.
info #next/swc-win32-ia32-msvc#12.3.0: The CPU architecture "x64" is incompatible with this module.
info #next/swc-darwin-arm64#12.3.0: The platform "linux" is incompatible with this module.
info "#next/swc-darwin-arm64#12.3.0" is an optional dependency and failed compatibility check. Excluding it from installation.
info #next/swc-darwin-arm64#12.3.0: The CPU architecture "x64" is incompatible with this module.
info #next/swc-linux-arm-gnueabihf#12.3.0: The CPU architecture "x64" is incompatible with this module.
info "#next/swc-linux-arm-gnueabihf#12.3.0" is an optional dependency and failed compatibility check. Excluding it from installation.
2022-10-01T05:04:04.332Z [INFO]: info fsevents#2.3.2: The platform "linux" is incompatible with this module.
2022-10-01T05:04:04.332Z [INFO]: info "fsevents#2.3.2" 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
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:
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
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
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,
}
I'm facing an error while running tests of an react app with testing-library and cypress. Tests running on unit test and e2e chrome is fine till it running on e2e firefox.
I haven't used firefox before, i was installed firefox from here to run the test on demand, but it doesn't seem to work. I've tried searching the internet for errors but couldn't find any similar articles.
Any ideas on how to solve this are welcome. Thank you all for reading.
Versions
"react": "^18.1.0",
"cypress": "^10.0.2",
"#cypress/react": "^5.12.5",
"#cypress/webpack-dev-server": "^1.8.4",
Config packages.json
"scripts": {
...
"test:all": "react-scripts test --transformIgnorePatterns \"node_modules/(?!#mui)/\" --watchAll=false && npm run test:e2e:all",
"test:unit": "react-scripts test --transformIgnorePatterns \"node_modules/(?!#mui)/\"",
"test:e2e:all": "npm run test:e2e:chrome && npm run test:e2e:firefox && npm run test:e2e:edge && npm run test:e2e:tablet",
"test:e2e:chrome": "npx cypress run --headless --browser chrome",
"test:e2e:firefox": "npx cypress run --headless --browser firefox",
"test:e2e:edge": "npx cypress run --headless --browser edge",
"test:e2e:tablet": "npx cypress run --headless --browser chrome --config viewportWidth=800"
},
Full log from terminal:
PS E:\react-todolist-recoil> yarn test:all
yarn run v1.22.4
$ react-scripts test --transformIgnorePatterns "node_modules/(?!#mui)/" --watchAll=false && npm run test:e2e:all
PASS src/pages/Fetch/fetch.test.tsx (6.236 s)
PASS src/pages/Home/home.test.tsx (15.773 s)
Test Suites: 2 passed, 2 total
Tests: 17 passed, 17 total
Snapshots: 0 total
Time: 17.798 s, estimated 18 s
Ran all test suites.
> react-todolist-recoil#0.1.0 test:e2e:all
> npm run test:e2e:chrome && npm run test:e2e:firefox && npm run test:e2e:edge && npm run test:e2e:tablet
> react-todolist-recoil#0.1.0 test:e2e:chrome
> npx cypress run --headless --browser chrome
====================================================================================================
(Run Starting)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Cypress: 10.0.2 │
│ Browser: Chrome 102 (headless) │
│ Node Version: v16.15.0 (C:\Program Files\nodejs\node.exe) │
│ Specs: 2 found (home.cy.ts, login.cy.ts) │
│ Searched: cypress/e2e/**/*.cy.{js,jsx,ts,tsx} │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
────────────────────────────────────────────────────────────────────────────────────────────────────
Running: home.cy.ts (1 of 2)
HomePage tests
√ truy cập, hiển thị các component quan trọng (1949ms)
√ home_toolbar: tiêu đề và các button (613ms)
√ home_toolbar: disable một số button khi không có dữ liệu (523ms)
√ home_toolbar: flow add dữ liệu (915ms)
√ home_toolbar: flow import dữ liệu từ file xlsx (623ms)
√ home_toolbar: flow xóa toàn bộ dữ liệu (523ms)
√ home_table: table row và các action button (492ms)
√ home_table: flow đánh dấu todo là đã hoàn thành (507ms)
√ home_table: flow cập nhật một table_row (todo) (1107ms)
√ home_table: flow xóa một table_row (todo) (602ms)
√ home_pagination: hiển thị dữ liệu giới hạn (1412ms)
√ home_pagination: hiển thị dữ liệu theo trang (947ms)
12 passing (10s)
(Results)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Tests: 12 │
│ Passing: 12 │
│ Failing: 0 │
│ Pending: 0 │
│ Skipped: 0 │
│ Screenshots: 0 │
│ Video: true │
│ Duration: 10 seconds │
│ Spec Ran: home.cy.ts │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
(Video)
- Started processing: Compressing to 32 CRF
- Finished processing: E:\react-todolist-recoil\cypress\videos\home.cy.ts.mp4 (2 seconds)
────────────────────────────────────────────────────────────────────────────────────────────────────
Running: login.cy.ts (2 of 2)
login.cy.ts
√ should visit (1094ms)
1 passing (1s)
(Results)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Tests: 1 │
│ Passing: 1 │
│ Failing: 0 │
│ Pending: 0 │
│ Skipped: 0 │
│ Screenshots: 0 │
│ Video: true │
│ Duration: 1 second │
│ Spec Ran: login.cy.ts │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
(Video)
- Started processing: Compressing to 32 CRF
- Finished processing: E:\react-todolist-recoil\cypress\videos\login.cy.ts.mp4 (0 seconds)
====================================================================================================
(Run Finished)
Spec Tests Passing Failing Pending Skipped
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ √ home.cy.ts 00:10 12 12 - - - │
├────────────────────────────────────────────────────────────────────────────────────────────────┤
│ √ login.cy.ts 00:01 1 1 - - - │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
√ All specs passed! 00:11 13 13 - - -
> react-todolist-recoil#0.1.0 test:e2e:firefox
> npx cypress run --headless --browser firefox
====================================================================================================
(Run Starting)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Cypress: 10.0.2 │
│ Browser: Firefox 101 (headless) │
│ Node Version: v16.15.0 (C:\Program Files\nodejs\node.exe) │
│ Specs: 2 found (home.cy.ts, login.cy.ts) │
│ Searched: cypress/e2e/**/*.cy.{js,jsx,ts,tsx} │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
────────────────────────────────────────────────────────────────────────────────────────────────────
Running: home.cy.ts (1 of 2)
Still waiting to connect to Firefox, retrying in 1 second (attempt 18/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 19/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 20/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 21/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 22/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 23/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 24/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 25/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 26/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 27/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 28/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 29/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 30/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 31/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 32/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 33/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 34/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 35/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 36/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 37/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 38/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 39/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 40/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 41/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 42/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 43/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 44/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 45/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 46/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 47/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 48/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 49/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 50/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 51/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 52/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 53/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 54/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 55/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 56/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 57/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 58/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 59/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 60/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 61/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 62/62)
Cypress failed to make a connection to Firefox.
This usually indicates there was a problem opening the Firefox browser.
Error: Could not find url target in browser about:blank. Targets were []
at C:\Users\IVS\AppData\Local\Cypress\Cache\10.0.2\Cypress\resources\app\packages\server\lib\browsers\browser-cri-client.js:90:27
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at retry (C:\Users\IVS\AppData\Local\Cypress\Cache\10.0.2\Cypress\resources\app\packages\server\lib\browsers\browser-cri-client.js:39:20)
at setupRemote (C:\Users\IVS\AppData\Local\Cypress\Cache\10.0.2\Cypress\resources\app\packages\server\lib\browsers\firefox-util.js:109:27)
error Command failed with exit code 1.
There's an open issue here "Still waiting to connect to Firefox" issue in Cypress 10.0.2 on Windows #22086.
I can confirm the same occurs on my system.
But, I can use Firefox nightly
script
"test:e2e:firefox": "npx cypress run --headless --browser firefox:nightly",
These are the paths used for Firefox (under C:/Program Files)
stable: getFirefoxPaths('Mozilla Firefox'),
dev: getFirefoxPaths('Firefox Developer Edition'),
nightly: getFirefoxPaths('Firefox Nightly'),
I have both "stable" (specified by --browser firefox) and "nightly" (specified by --browser firefox:nightly) but I can't see why "stable" isn't firing up. It seems to be installed the same way a "nightly"
I learned how to use Container Registry trigger for Google Cloud Functions deploy from the following tutorial.
Automatic serverless deployments with Cloud Source Repositories and Container Builder
I have Google App engine flexible app. The runtime is Node.js. I want to deploy the app triggered by git push. Are there any good references?
I'm using these example code. Manual deployment works normally.
* tree
.
├── app.js
├── app.yaml
└── package.json
* app.js
'use strict';
const express = require('express');
const app = express();
app.get('/', (req, res) => {
res.status(200).send('Hello, world!').end();
});
const PORT = process.env.PORT || 8080;
app.listen(PORT, () => {
console.log(`App listening on port ${PORT}`);
console.log('Press Ctrl+C to quit.');
});
* app.yaml
runtime: nodejs
env: flex
* package.json
{
"name": "appengine-hello-world",
"description": "Simple Hello World Node.js sample for Google App Engine Flexible Environment.",
"version": "0.0.1",
"private": true,
"license": "Apache-2.0",
"author": "Google Inc.",
"repository": {
"type": "git",
"url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git"
},
"engines": {
"node": ">=4.3.2"
},
"scripts": {
"deploy": "gcloud app deploy",
"start": "node app.js",
"lint": "samples lint",
"pretest": "npm run lint",
"system-test": "samples test app",
"test": "npm run system-test",
"e2e-test": "samples test deploy"
},
"dependencies": {
"express": "4.15.4"
},
"devDependencies": {
"#google-cloud/nodejs-repo-tools": "1.4.17"
},
"cloud-repo-tools": {
"test": {
"app": {
"msg": "Hello, world!"
}
},
"requiresKeyFile": true,
"requiresProjectId": true
}
}
* deploy command
$ gcloud app deploy
Update 1
I found a similar question.
How to auto deploy google app engine flexible using Container Registry with Build Trigger
I added cloudbuild.yaml.
steps:
# Build the Docker image.
- name: gcr.io/cloud-builders/docker
args: ['build', '-t', 'gcr.io/$PROJECT_ID/app', '.']
# Push it to GCR.
- name: gcr.io/cloud-builders/docker
args: ['push', 'gcr.io/$PROJECT_ID/app']
# Deploy your Flex app from the image in GCR.
- name: gcr.io/cloud-builders/gcloud
args: ['app', 'deploy', 'app.yaml', '--image-url=gcr.io/$PROJECT_ID/app']
# Note that this build pushes this image.
images: ['gcr.io/$PROJECT_ID/app']
However, I got an error. The error message is "error loading template: yaml: line 5: did not find expected key". I'm looking into it.
Update 2
The reason was invalid yaml format. I changed it like the following.
steps:
# Build the Docker image.
- name: gcr.io/cloud-builders/docker
args: ['build', '-t', 'gcr.io/$PROJECT_ID/app', '.']
# Push it to GCR.
- name: gcr.io/cloud-builders/docker
args: ['push', 'gcr.io/$PROJECT_ID/app']
# Deploy your Flex app from the image in GCR.
- name: gcr.io/cloud-builders/gcloud
args: ['app', 'deploy', 'app.yaml', '--image-url=gcr.io/$PROJECT_ID/app']
# Note that this build pushes this image.
images: ['gcr.io/$PROJECT_ID/app']
I got another error. The message is "error loading template: unknown field "images" in cloudbuild_go_proto.BuildStep"
Update 3
I noticed that "images" indent was wrong.
steps:
...
# Note that this build pushes this image.
images: ['gcr.io/$PROJECT_ID/app']
I encountered new error.
starting build "e3e00749-9c70-4ac7-a322-d096625b695a"
FETCHSOURCE
Initialized empty Git repository in /workspace/.git/
From https://source.developers.google.com/p/xxxx/r/bitbucket-zono-api-btc
* branch 0da6c8bf209c72b6406f3801f3eb66d346187f4e -> FETCH_HEAD
HEAD is now at 0da6c8b fix invalid yaml
BUILD
Starting Step #0
Step #0: Already have image (with digest): gcr.io/cloud-builders/docker
Step #0: unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /workspace/Dockerfile: no such file or directory
Finished Step #0
ERROR
ERROR: build step 0 "gcr.io/cloud-builders/docker" failed: exit status 1
Yes. I don't have Dockerfile because I use Google App Engine flexible Environment Node.js runtime. It is not necessary Docker.
Update 4
I added Dockerfile
FROM gcr.io/google-appengine/nodejs
Then new error was occurred.
Step #2: ERROR: (gcloud.app.deploy) User [xxxxxxx#cloudbuild.gserviceaccount.com] does not have permission to access app [xxxx] (or it may not exist): App Engine Admin API has not been used in project xxx before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/appengine.googleapis.com/overview?project=xxx then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.
Update 5
I enabled App Engine Admin API then next error has come.
Step #2: Do you want to continue (Y/n)?
Step #2: WARNING: Unable to verify that the Appengine Flexible API is enabled for project [xxx]. You may not have permission to list enabled services on this project. If it is not enabled, this may cause problems in running your deployment. Please ask the project owner to ensure that the Appengine Flexible API has been enabled and that this account has permission to list enabled APIs.
Step #2: Beginning deployment of service [default]...
Step #2: WARNING: Deployment of service [default] will ignore the skip_files field in the configuration file, because the image has already been built.
Step #2: Updating service [default] (this may take several minutes)...
Step #2: ...............................................................................................................................failed.
Step #2: ERROR: (gcloud.app.deploy) Error Response: [9]
Step #2: Application startup error:
Step #2: npm ERR! path /app/package.json
Step #2: npm ERR! code ENOENT
Step #2: npm ERR! errno -2
Step #2: npm ERR! syscall open
Step #2: npm ERR! enoent ENOENT: no such file or directory, open '/app/package.json'
Step #2: npm ERR! enoent This is related to npm not being able to find a file.
I changed my code tree but it did not work. I confirmed that Appengine Flexible API has been enabled. I have no idea what should I try next.
.
├── Dockerfile
├── app
│ ├── app.js
│ └── package.json
├── app.yaml
└── cloudbuild.yaml
Update 6
When I deploy manually, the artifact is like the following.
us.gcr.io/xxxxx/appengine/default.20180316t000144
Should I use this artifact...? I'm confused..
Update 7
Two builds are executed. I don't know whether this is correct.
Your Dockerfile doesn't copy source to the image.
You can move everything back to the same directory such that
.
├── app.js
├── app.yaml
├── cloudbuild.yaml
├── Dockerfile
└── package.json
but it doesn't matter.
Paste this into your Dockerfile and it should work:
FROM gcr.io/google-appengine/nodejs
# Working directory is where files are stored, npm is installed, and the application is launched
WORKDIR /app
# Copy application to the /app directory.
# Add only the package.json before running 'npm install' so 'npm install' is not run if there are only code changes, no package changes
COPY package.json /app/package.json
RUN npm install
COPY . /app
# Expose port so when container is launched you can curl/see it.
EXPOSE 8080
# The command to execute when Docker image launches.
CMD ["npm", "start"]
Edit: This is the cloudbuild.yaml I used:
steps:
- name: gcr.io/cloud-builders/docker
args: ['build', '-t', 'gcr.io/$PROJECT_ID/app', '.']
- name: gcr.io/cloud-builders/docker
args: ['push', 'gcr.io/$PROJECT_ID/app']
- name: gcr.io/cloud-builders/gcloud
args: ['app', 'deploy', 'app.yaml', '--image-url=gcr.io/$PROJECT_ID/app']
images: ['gcr.io/$PROJECT_ID/app']
A tech guy helped me. I changed directory structure and cloudbuild.yaml. Then it worked. Thanks.
* Code Tree
.
├── app
│ ├── app.js
│ ├── app.yaml
│ └── package.json
└── cloudbuild.yaml
* cloudbuild.yaml
steps:
- name: gcr.io/cloud-builders/npm
args: ['install', 'app']
- name: 'gcr.io/cloud-builders/gcloud'
args: ['app', 'deploy', 'app/app.yaml']