Failed to load next.config.js on deploying NextJS to AWS EC2 instance using Codepipeline - amazon-ec2

ready - started server on 0.0.0.0:3000, url: http://localhost:3000
3|customapp | (node:1340043) UnhandledPromiseRejectionWarning: /app/node_modules/next/dist/server/next-server.js:91
3|customapp | compression = this.nextConfig.compress && this.nextConfig.target === "server" ? (0, _compression).default() : undefined;
3|customapp | ^
3|customapp | SyntaxError: Unexpected token =
3|customapp | at Module._compile (internal/modules/cjs/loader.js:723:23)
3|customapp | at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
3|customapp | at Module.load (internal/modules/cjs/loader.js:653:32)
3|customapp | at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
3|customapp | at Function.Module._load (internal/modules/cjs/loader.js:585:3)
3|customapp | at Module.require (internal/modules/cjs/loader.js:692:17)
3|customapp | at require (internal/modules/cjs/helpers.js:25:18)
3|customapp | at Timeout.getServerImpl [as _onTimeout] (/app/node_modules/next/dist/server/next.js:59:71)
3|customapp | at ontimeout (timers.js:436:11)
3|customapp | at tryOnTimeout (timers.js:300:5)
3|customapp | (node:1340043) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
3|customapp | (node:1340043) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
3|customapp | error - Failed to load next.config.js, see more info here https://nextjs.org/docs/messages/next-config-error
3|customapp | Error: Not supported
3|customapp | at Object.loadConfig [as default] (/app/node_modules/next/dist/server/config.js:68:78)
3|customapp | npm
3|customapp | ERR! code ELIFECYCLE
This is the error I'm getting when trying to deploy NextJS to EC2 instance through code pipeline. When i try to run the app using pm2 start inside EC2 instance, it allows me. But through code pipeline, it shows errors. The Deployment stage seems completed, but when i took the logs of the pm2 this happens.
I was following https://gist.github.com/ArcRanges/3d1d95421984c40fffaf3fabc9ea7396
I was trying to get the app work, by testing curl --location --request GET 'http://localhost:3000/api/say' .
but it returned Connection refused ERR.
Then i tried pm2 log and got the above error regarding next.config.js
This is my next.config.js file
/** #type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
swcMinify: true,
};
module.exports = nextConfig;
buildspec.yml
version: 0.2
phases:
install:
runtime-versions:
nodejs: 16.x
commands:
# install npm
- npm install -f
- npm install next -g
build:
commands:
# run build script
- npm run build
artifacts:
# include all files required to run application
# notably excluded is node_modules, as this will cause overwrite error on deploy
files:
- assets/**/*
- components/**/*
- containers/**/*
- pages/**/*
- public/**/*
- scripts/**/*
- settings/**/*
- styles/**/*
- tsconfig.json
- package.json
- appspec.yml
- postcss.config.js
- tailwind.config.js
- next.config.js
appspec.yml
version: 0.0
os: linux
files:
- source: /
destination: /app
overwrite: true
permissions:
- object: /
pattern: "**"
owner: root
group:
hooks:
BeforeInstall:
- location: scripts/before_install.sh
timeout: 300
runas: root
AfterInstall:
- location: scripts/after_install.sh
timeout: 300
runas: root
ApplicationStart:
- location: scripts/application_start.sh
timeout: 300
runas: root
scripts/before_install.sh
#!/bin/bash
cd /app
curl -sL https://rpm.nodesource.com/setup_16.x | sudo -E bash -
apt -y install nodejs npm
scripts/after_install.sh
#!/bin/bash
cd /app
npm install -f
npm install pm2 -g
scripts/application_start.sh
#!/bin/bash
cd /app
npm run build
echo "After Build"
node -e "console.log('Running node.js '+process.version)"
pm2 start npm --name "customapp" -- start
pm2 startup
pm2 save
pm2 restart all

Related

Resource not accessible by integration

I have this weird error when Cypress GitHub Action can't successfully complete whilst CLI command is doing just fine.
Here is how I tried to do it originally with GitHub Action:
- name: Run acceptance tests with Cypress 📝
uses: cypress-io/github-action#v2
with:
working-directory: e2e
browser: chrome
record: true
parallel: true
start: npm run start-server
wait-on: 'http://localhost:1080'
wait-on-timeout: 360
env:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
MIX_ENV: acceptance_tests
DEBUG: '#cypress/github-action'
Here is my cypress.json config - you can see that wait-on and baseUrl are pointing to the same URL:
{
"testFiles": "**/*.feature",
"projectId": "...",
"baseUrl": "http://localhost:1080"
}
And the fun fact is that app under test responds to at least one request!
arning: 2022-05-18T21:04:34.089Z #cypress/github-action Separated 1 start commands npm run app_server
start server "npm run app_server command "npm run app_server"
current working directory "/__w/mimisbrunnr/mimisbrunnr/e2e"
2022-05-18T21:04:34.090Z #cypress/github-action parsed command: npm run app_server
waiting on "http://localhost:1080" with timeout of 60 seconds
Warning: 2022-05-18T21:04:34.091Z #cypress/github-action Waiting for urls http://localhost:1080
2022-05-18T21:04:34.092Z #cypress/github-action Waiting for url http://localhost:1080
Warning: 2022-05-18T21:04:34.092Z #cypress/github-action total ping timeout 90000
2022-05-18T21:04:34.092Z #cypress/github-action individual ping timeout 30000ms
Warning: 2022-05-18T21:04:34.092Z #cypress/github-action retries limit 3
2022-05-18T21:04:34.107Z #cypress/github-action got error {"name":"RequestError","code":"ECONNREFUSED","timings":{"start":1652907874098,"socket":1652907874099,"lookup":1652907874100,"error":1652907874101,"phases":{"wait":1,"dns":1,"total":3}}}
Warning: 2022-05-18T21:04:34.107Z #cypress/github-action 15ms undefined undefined ECONNREFUSED attempt 1
2022-05-18T21:04:34.108Z #cypress/github-action found command "/usr/local/bin/npm"
Warning: 2022-05-18T21:04:34.108Z #cypress/github-action with arguments run app_server
2022-05-18T21:04:34.108Z #cypress/github-action running "/usr/local/bin/npm" run app_server in /__w/mimisbrunnr/mimisbrunnr/e2e
Warning: 2022-05-18T21:04:34.108Z #cypress/github-action waiting for the command to finish? false
/usr/local/bin/npm run app_server
> gjallarhorn#1.0.0 app_server
> cd ../main && mix phx.server
here it comes ->
warning: the VM is running with native name encoding of latin1 which may cause Elixir to malfunction as it expects utf8. Please ensure your locale is set to UTF-8 (which can be verified by running "locale" in your shell)
2022-05-18T21:04:35.109Z #cypress/github-action got error {"name":"RequestError","code":"ECONNREFUSED","timings":{"start":1652907875108,"socket":1652907875108,"lookup":1652907875108,"error":1652907875109,"phases":{"wait":0,"dns":0,"total":1}}}
Warning: 2022-05-18T21:04:35.109Z #cypress/github-action 1017ms undefined undefined ECONNREFUSED attempt 2
21:04:35.419 [info] Running MimisbrunnrWeb.Endpoint with cowboy 2.9.0 at 127.0.0.1:1080 (http)
21:04:35.428 [info] Access MimisbrunnrWeb.Endpoint at http://localhost:1080
[+] Starting static assets build with esbuild. Build mode development...
[+] Starting static assets build with esbuild. Build mode development...
21:04:36.251 request_id=FvBO9LpFQLx0rPYAAAFx [info] GET /
21:04:36.339 request_id=FvBO9LpFQLx0rPYAAAFx [info] Sent 200 in 87ms
2022-05-18T21:04:36.348Z #cypress/github-action pinging http://localhost:1080 has finished ok after 2256ms
but even though cypress successfully pinged the main app the party is still over
Warning: 2022-05-18T21:04:36.349Z #cypress/github-action Running Cypress tests using NPM module API
2022-05-18T21:04:36.349Z #cypress/github-action requiring cypress dependency, cwd is /__w/mimisbrunnr/mimisbrunnr
Warning: 2022-05-18T21:04:36.349Z #cypress/github-action working directory /__w/mimisbrunnr/mimisbrunnr/e2e
2022-05-18T21:04:36.351Z #cypress/github-action resolved cypress /__w/mimisbrunnr/mimisbrunnr/e2e/node_modules/cypress/index.js
Warning: 2022-05-18T21:04:36.721Z #cypress/github-action Cypress config "pageLoadTimeout=100000,baseUrl=http://localhost:1080"
2022-05-18T21:04:36.722Z #cypress/github-action Determining build id by asking GitHub about run 2348169225
Warning: 2022-05-18T21:04:36.841Z #cypress/github-action Resource not accessible by integration
2022-05-18T21:04:36.841Z #cypress/github-action HttpError: Resource not accessible by integration
Warning: at /__w/_actions/cypress-io/github-action/v2/dist/index.js:58740:21
at processTicksAndRejections (internal/process/task_queues.js:97:5)
Warning: at async getCiBuildId (/__w/_actions/cypress-io/github-action/v2/dist/index.js:6230:18)
at async runTests (/__w/_actions/cypress-io/github-action/v2/dist/index.js:6468:33)
Error: Resource not accessible by integration
Ok. Fair enough, but look - it's all fine with a simple CLI command run through start-server-and-test. Here is the relevant part of the package.json:
"scripts": {
"test": "cypress run",
"start-server": "cd ../main && mix phx.server",
"ci": "start-server-and-test start-server http://localhost:1080 test"
}
and GitHub Action step:
- name: Run acceptance tests with Cypress
run: npm run ci
working-directory: e2e
env:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
MIX_ENV: acceptance_tests
START_SERVER_AND_TEST_INSECURE: 1
DEBUG: start-server-and-test
and logs:
making HTTP(S) head request to url:http://localhost:1080 ...
21:40:36.375 request_id=FvBQ66vDSZ10rPYAAAES [info] HEAD /
21:40:36.548 request_id=FvBQ66vDSZ10rPYAAAES [info] Sent 200 in 172ms
HTTP(S) result for http://localhost:1080: {
Warning: status: 200,
statusText: 'OK',
headers: {
'cache-control': 'max-age=0, private, must-revalidate',
connection: 'close',
'content-length': '3910',
'content-type': 'text/html; charset=utf-8',
'cross-origin-window-policy': 'deny',
date: 'Wed, 18 May 2022 21:40:36 GMT',
Warning: server: 'Cowboy',
'x-content-type-options': 'nosniff',
'x-download-options': 'noopen',
'x-frame-options': 'SAMEORIGIN',
'x-permitted-cross-domain-policies': 'none',
'x-request-id': 'FvBQ66vDSZ10rPYAAAES',
'x-xss-protection': '1; mode=block',
'set-cookie': [
'_app_web_key=SFMyNTY.g3QAAAABbQAAAAtfY3NyZl90b2tlbm0AAAAYdmc0cXlvMkVha3JhcS1hVEJpalFxQ0J5.28LG5PrAPHrEQfvD1fpHR2-pLeEDgRrZkox8--yxP9M; path=/; HttpOnly'
]
},
data: ''
}
2022-05-18T21:40:36.564Z start-server-and-test waitOn finished successfully
Warning: 2022-05-18T21:40:36.565Z start-server-and-test running test script command: npm run test
wait-on(3361) complete
[+] Esbuild /__w/mimisbrunnr/mimisbrunnr/main/apps/mimisbrunnr_web/assets/js/app.js to /__w/mimisbrunnr/mimisbrunnr/main/apps/mimisbrunnr_web/priv/static/assets/app.js succeeded.
[+] Esbuild /__w/mimisbrunnr/mimisbrunnr/main/apps/mimisbrunnr_web/assets/css/app.scss to /__w/mimisbrunnr/mimisbrunnr/main/apps/mimisbrunnr_web/priv/static/assets/app.css succeeded.
> gjallarhorn#1.0.0 test
> cypress run
[3631:0518/214038.922826:ERROR:gpu_init.cc(453)] Passthrough is not supported, GL is swiftshader, ANGLE is
mail server at port 7777
====================================================================================================
(Run Starting)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Cypress: 9.6.0 │
│ Browser: Electron 94 (headless) │
│ Node Version: v16.14.0 (/usr/local/bin/node) │
│ Specs: 2 found (patient_dashboard.feature, sign_up.feature) │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
So my question is what exactly resource is not accessible by the integration?

ParcelJS 2 not working with Yarn 3 with PnP linker

I'm creating an empty project with yarn 3.2.0:
$ corepack prepare --activate yarn#3.2.0
Preparing yarn#3.2.0 for immediate activation...
$ yarn init
{
name: 'yarn-parcel',
packageManager: 'yarn#3.2.0'
}
Then I add parcel package: (version 2.4.1 is installed)
$ yarn add -D parcel
...
And then I create an index.html and run parcel:
$ echo '<body>Hello</body>' > index.html
$ yarn parcel ./index.html
And it gives me this error:
Server running at http://localhost:1234
🚨 Build failed.
#parcel/transformer-js: Could not resolve module "#parcel/core" from
"/home/shayan/Coding/yarn-parcel/.yarn/__virtual__/#parcel-workers-virtual-7d738da563/0/cache/#parcel-workers-npm-2.4.1-6f10a6c026-bc55779f8d.zip/node_modules/#parcel/workers/lib/Handle.js"
Error: Could not resolve module "#parcel/core" from
"/home/shayan/Coding/yarn-parcel/.yarn/__virtual__/#parcel-workers-virtual-7d738da563/0/cache/#parcel-workers-npm-2.4.1-6f10a6c026-bc55779f8d.zip/node_modules/#parcel/workers/lib/Handle.js"
at $0578d0f6e116167e$export$fb2a0b866a8162dc.resolve
(/home/shayan/Coding/yarn-parcel/.yarn/__virtual__/#parcel-package-manager-virtual-9893719388/0/cache/#parcel-package-manager-npm-2.4.1-fee8a770b4-7ca98814d5.zip/node_modules/#parcel/package-manager/lib/index.js:4919:21)
at NodePackageManager.resolveSync
(/home/shayan/Coding/yarn-parcel/.yarn/__virtual__/#parcel-package-manager-virtual-9893719388/0/cache/#parcel-package-manager-npm-2.4.1-fee8a770b4-7ca98814d5.zip/node_modules/#parcel/package-manager/lib/index.js:3510:42)
at NodePackageManager.requireSync
(/home/shayan/Coding/yarn-parcel/.yarn/__virtual__/#parcel-package-manager-virtual-9893719388/0/cache/#parcel-package-manager-npm-2.4.1-fee8a770b4-7ca98814d5.zip/node_modules/#parcel/package-manager/lib/index.js:3351:34)
at Module.m.require
(/home/shayan/Coding/yarn-parcel/.yarn/__virtual__/#parcel-package-manager-virtual-9893719388/0/cache/#parcel-package-manager-npm-2.4.1-fee8a770b4-7ca98814d5.zip/node_modules/#parcel/package-manager/lib/index.js:3365:25)
at require (node:internal/modules/cjs/helpers:102:18)
at _core
(/home/shayan/Coding/yarn-parcel/.yarn/__virtual__/#parcel-workers-virtual-7d738da563/0/cache/#parcel-workers-npm-2.4.1-6f10a6c026-bc55779f8d.zip/node_modules/#parcel/workers/lib/Handle.js:9:16)
at Object.<anonymous>
(/home/shayan/Coding/yarn-parcel/.yarn/__virtual__/#parcel-workers-virtual-7d738da563/0/cache/#parcel-workers-npm-2.4.1-6f10a6c026-bc55779f8d.zip/node_modules/#parcel/workers/lib/Handle.js:57:5)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
at Object.require$$0.Module._extensions..js (/home/shayan/Coding/yarn-parcel/.pnp.cjs:11439:33)
(Adding --log-level verbose does not add any details.)
The problem is with nodeLinker: pnp. If I set nodeLinker: node-modules, then it works fine.
Unplugging parcel did not help.
What can I do?

Yarn module not found error in azure pipelines via cache mechanism

thank you in advance for looking at this issue for me.
Am working on improving our CI build times in azure devops pipelines via this caching mechanism that is offered. Am also using the cache restored boolean function mentioned in the link.
The summary of the steps are as per screenshot below
Summary of Steps
Check cache for yarn packages.
Retrieve packages from cache if there is a cache hit
Skip the yarn install step which pulls packages from public source and takes some time if there is a cache hit.
Run yarn Build.
The issue appears specfically in the yarn build step where it complains about not being able to find a node_module as per below error log.
2020-10-12T21:28:00.1761207Z ##[section]Starting: yarn build
2020-10-12T21:28:00.1884736Z ==============================================================================
2020-10-12T21:28:00.1885119Z Task : PowerShell
2020-10-12T21:28:00.1885475Z Description : Run a PowerShell script on Linux, macOS, or Windows
2020-10-12T21:28:00.1885806Z Version : 2.170.1
2020-10-12T21:28:00.1886094Z Author : Microsoft Corporation
2020-10-12T21:28:00.1886495Z Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/utility/powershell
2020-10-12T21:28:00.1886967Z ==============================================================================
2020-10-12T21:28:01.0882035Z Generating script.
2020-10-12T21:28:01.1294597Z ========================== Starting Command Output ===========================
2020-10-12T21:28:01.1574727Z ##[command]"C:\windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". 'D:\a\_temp\24379d8e-967c-4af6-9674-96aa85df30a4.ps1'"
2020-10-12T21:28:06.5140487Z yarn run v1.22.10
2020-10-12T21:28:06.5712118Z $ yarn run clean:builddir
2020-10-12T21:28:07.7032890Z $ npx rimraf ./Scripts/build
2020-10-12T21:28:31.4416409Z npx: installed 12 in 14.71s
2020-10-12T21:28:31.5265827Z $ npx concurrently --names "app,workspaces" "npx cross-env NODE_OPTIONS=--max-old-space-size=8192 npx webpack --mode production" "yarn wsrun -m --parallel build:prod" --verbose
2020-10-12T21:28:43.6196644Z npx: installed 54 in 11.679s
2020-10-12T21:28:44.5023615Z [workspaces] error Command "wsrun" not found.
2020-10-12T21:28:44.5026888Z [workspaces] info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
2020-10-12T21:28:44.5030627Z [workspaces] yarn wsrun -m --parallel build:prod exited with code 1
2020-10-12T21:28:46.4240020Z [app] npx: installed 7 in 1.967s
2020-10-12T21:29:09.1434285Z [app] C:\npm\prefix\node_modules\webpack-cli\bin\cli.js:93
2020-10-12T21:29:09.1435399Z [app] throw err;
2020-10-12T21:29:09.1435915Z [app] ^
2020-10-12T21:29:09.1436363Z [app]
2020-10-12T21:29:09.1436924Z [app] Error: Cannot find module 'webpack-bundle-analyzer'
2020-10-12T21:29:09.1437490Z [app] Require stack:
2020-10-12T21:29:09.1438065Z [app] - D:\a\1\s\Abstracted.Web.App\webpack.config.js
2020-10-12T21:29:09.1438780Z [app] - C:\npm\prefix\node_modules\webpack-cli\bin\utils\convert-argv.js
2020-10-12T21:29:09.1441594Z [app] - C:\npm\prefix\node_modules\webpack-cli\bin\cli.js
2020-10-12T21:29:09.1442320Z [app] - C:\npm\prefix\node_modules\webpack\bin\webpack.js
2020-10-12T21:29:09.1443090Z [app] at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
2020-10-12T21:29:09.1443973Z [app] at Function.Module._load (internal/modules/cjs/loader.js:841:27)
2020-10-12T21:29:09.1445082Z [app] at Module.require (internal/modules/cjs/loader.js:1025:19)
2020-10-12T21:29:09.1446059Z [app] at require (C:\npm\prefix\node_modules\webpack-cli\node_modules\v8-compile-cache\v8-compile-cache.js:161:20)
2020-10-12T21:29:09.1447302Z [app] at Object.<anonymous> (D:\a\1\s\Abstracted.Web.App\webpack.config.js:3:30)
2020-10-12T21:29:09.1448348Z [app] at Module._compile (C:\npm\prefix\node_modules\webpack-cli\node_modules\v8-compile-cache\v8-compile-cache.js:194:30)
2020-10-12T21:29:09.1449351Z [app] at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
2020-10-12T21:29:09.1450132Z [app] at Module.load (internal/modules/cjs/loader.js:985:32)
2020-10-12T21:29:09.1453332Z [app] at Function.Module._load (internal/modules/cjs/loader.js:878:14)
2020-10-12T21:29:09.1454342Z [app] at Module.require (internal/modules/cjs/loader.js:1025:19)
2020-10-12T21:29:09.1455342Z [app] at require (C:\npm\prefix\node_modules\webpack-cli\node_modules\v8-compile-cache\v8-compile-cache.js:161:20)
2020-10-12T21:29:09.1456524Z [app] at WEBPACK_OPTIONS (C:\npm\prefix\node_modules\webpack-cli\bin\utils\convert-argv.js:114:13)
2020-10-12T21:29:09.1457530Z [app] at requireConfig (C:\npm\prefix\node_modules\webpack-cli\bin\utils\convert-argv.js:116:6)
2020-10-12T21:29:09.1460155Z [app] at C:\npm\prefix\node_modules\webpack-cli\bin\utils\convert-argv.js:123:17
2020-10-12T21:29:09.1460996Z [app] at Array.forEach (<anonymous>)
2020-10-12T21:29:09.1461622Z [app] at module.exports (C:\npm\prefix\node_modules\webpack-cli\bin\utils\convert-argv.js:121:15)
2020-10-12T21:29:09.1462534Z [app] at C:\npm\prefix\node_modules\webpack-cli\bin\cli.js:71:45
2020-10-12T21:29:09.1463445Z [app] at Object.parse (C:\npm\prefix\node_modules\webpack-cli\node_modules\yargs\yargs.js:576:18)
2020-10-12T21:29:09.1464195Z [app] at C:\npm\prefix\node_modules\webpack-cli\bin\cli.js:49:8
2020-10-12T21:29:09.1465077Z [app] at Object.<anonymous> (C:\npm\prefix\node_modules\webpack-cli\bin\cli.js:366:3)
2020-10-12T21:29:09.1465949Z [app] at Module._compile (internal/modules/cjs/loader.js:1137:30)
2020-10-12T21:29:09.1467013Z [app] at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
2020-10-12T21:29:09.1467607Z [app] at Module.load (internal/modules/cjs/loader.js:985:32)
2020-10-12T21:29:09.1468654Z [app] at Function.Module._load (internal/modules/cjs/loader.js:878:14)
2020-10-12T21:29:09.1469217Z [app] at Module.require (internal/modules/cjs/loader.js:1025:19)
2020-10-12T21:29:09.1469969Z [app] at require (internal/modules/cjs/helpers.js:72:18)
2020-10-12T21:29:09.1470800Z [app] at Object.<anonymous> (C:\npm\prefix\node_modules\webpack\bin\webpack.js:156:2)
2020-10-12T21:29:09.1471434Z [app] at Module._compile (internal/modules/cjs/loader.js:1137:30)
2020-10-12T21:29:09.1472287Z [app] at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
2020-10-12T21:29:09.1473085Z [app] at Module.load (internal/modules/cjs/loader.js:985:32) {
2020-10-12T21:29:09.1473556Z [app] code: 'MODULE_NOT_FOUND',
2020-10-12T21:29:09.1474272Z [app] requireStack: [
2020-10-12T21:29:09.1474736Z [app] 'D:\\a\\1\\s\\Abstracted.Web.App\\webpack.config.js',
2020-10-12T21:29:09.1475804Z [app] 'C:\\npm\\prefix\\node_modules\\webpack-cli\\bin\\utils\\convert-argv.js',
2020-10-12T21:29:09.1476626Z [app] 'C:\\npm\\prefix\\node_modules\\webpack-cli\\bin\\cli.js',
2020-10-12T21:29:09.1477161Z [app] 'C:\\npm\\prefix\\node_modules\\webpack\\bin\\webpack.js'
2020-10-12T21:29:09.1477854Z [app] ]
2020-10-12T21:29:09.1478179Z [app] }
2020-10-12T21:29:09.2871272Z [app] npx cross-env NODE_OPTIONS=--max-old-space-size=8192 npx webpack --mode production exited with code 1
2020-10-12T21:29:11.8915556Z error Command failed with exit code 1.
2020-10-12T21:29:11.8918295Z info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
2020-10-12T21:29:12.1132424Z ##[error]PowerShell exited with code '1'.
2020-10-12T21:29:12.2192481Z ##[section]Finishing: yarn build
I have placed a debug step as per below results and can see that there is definitely a module restored with the name mentioned.
Question
I am wondering where the problem might be as I am not sure why the yarn build step is unable to see the cache module even though I set a value for YARN_CACHE_FOLDER = $(Pipeline.Workspace)\.yarn and I can see the build module in the debug.
Things I have tried.
If I do not skip the yarn install step everything works fine.
Have passed the yarn build command with input of --cache-folder $(YARN_CACHE_FOLDER)
Have set npm_config_cache variable pointing to same location as yarn cache folder as I can see that yarn ultimately is yarn --> npm --> npx
Have set npm config set cache $(YARN_CACHE_FOLDER) --global
debug cache folder results
2020-10-12T21:27:57.9564700Z ##[command]"C:\windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". 'D:\a\_temp\41464daa-068a-4419-b4ee-a22669f1d505.ps1'"
2020-10-12T21:27:58.2263973Z Yarn Cache Folder: D:\a\1\.yarn
2020-10-12T21:27:58.2878796Z
2020-10-12T21:27:58.2879351Z
2020-10-12T21:27:58.2882145Z Directory: D:\a\1\.yarn
2020-10-12T21:27:58.2882732Z
2020-10-12T21:27:58.2883036Z
2020-10-12T21:27:58.2889439Z Mode LastWriteTime Length Name
2020-10-12T21:27:58.2892321Z ---- ------------- ------ ----
2020-10-12T21:27:58.2897508Z d----- 10/12/2020 9:14 PM v6
2020-10-12T21:27:58.3052399Z
2020-10-12T21:27:58.3052981Z
2020-10-12T21:27:58.3053995Z Directory: D:\a\1\.yarn\v6
2020-10-12T21:27:58.3054249Z
2020-10-12T21:27:58.3054668Z
2020-10-12T21:27:58.3059237Z Mode LastWriteTime Length Name
2020-10-12T21:27:58.3061399Z ---- ------------- ------ ----
2020-10-12T21:27:58.3090817Z d----- 10/12/2020 9:13 PM npm-webpack-bundle-analyzer-3.8.0-ce6b3f908daf069fd1f7266f692cbb3bded9
2020-10-12T21:27:58.3091604Z ba16-integrity
2020-10-12T21:28:00.0136005Z
2020-10-12T21:28:00.0137465Z
2020-10-12T21:28:00.0139239Z Directory:
2020-10-12T21:28:00.0140339Z D:\a\1\.yarn\v6\npm-webpack-bundle-analyzer-3.8.0-ce6b3f908daf069fd1f7266f692cbb3bded9ba16-integrity\node_modules
2020-10-12T21:28:00.0141165Z
2020-10-12T21:28:00.0142124Z
2020-10-12T21:28:00.0145599Z Mode LastWriteTime Length Name
2020-10-12T21:28:00.0148653Z ---- ------------- ------ ----
2020-10-12T21:28:00.0286731Z d----- 10/12/2020 9:13 PM webpack-bundle-analyzer
2020-10-12T21:28:00.0320519Z
2020-10-12T21:28:00.0321138Z
2020-10-12T21:28:00.0365021Z Directory: D:\a\1\.yarn\v6\npm-webpack-bundle-analyzer-3.8.0-ce6b3f908daf069fd1f7266f692cbb3bded9ba16-integrity\nod
2020-10-12T21:28:00.0365533Z e_modules\webpack-bundle-analyzer\.bin
2020-10-12T21:28:00.0365731Z
2020-10-12T21:28:00.0365869Z
2020-10-12T21:28:00.0370893Z Mode LastWriteTime Length Name
2020-10-12T21:28:00.0373787Z ---- ------------- ------ ----
2020-10-12T21:28:00.0378379Z -a---- 10/12/2020 9:13 PM 309 webpack-bundle-analyzer
2020-10-12T21:28:00.0390041Z -a---- 10/12/2020 9:13 PM 186 webpack-bundle-analyzer.cmd
2020-10-12T21:28:00.0964047Z
2020-10-12T21:28:00.0964303Z
2020-10-12T21:28:00.1723744Z ##[section]Finishing: debug cache folder
Abstracted YAML of Pipeline Definition
variables:
- name: System.Debug
value: false
- name: YARN_CACHE_FOLDER
value: $(Pipeline.Workspace)\.yarn
- name: npm_config_cache
value: $(Pipeline.Workspace)\.yarn\v6
stages:
# Build All Apps
- stage: Stage1
displayName: Build
condition: true
jobs:
- job: BuildCI
condition: succeeded()
steps:
- checkout: self
fetchDepth: 1
- task: Cache#2
displayName: Cache Yarn packages
# condition: false
inputs:
key: 'yarn | "$(Agent.OS)" | CompanyName.Web.App\yarn.lock'
restoreKeys: |
yarn | "$(Agent.OS)"
path: $(YARN_CACHE_FOLDER)
cacheHitVar: CACHE_RESTORED
- powershell: |
Write-Host "Yarn Cache Folder: $(YARN_CACHE_FOLDER)"
Write-Host "Searching Pipeline.Workspace Folder for WebPack"
gci $(Pipeline.Workspace) -filter "*webpack-bundle-analyzer*" -recurse | Select FullName
#condition: false
displayName: 'debug folder'
- task: Yarn#2
displayName: 'Yarn Install Web.App'
# condition: succeeded()
condition: |
and
(
succeeded(),
ne(variables.CACHE_RESTORED, 'false')
)
inputs:
ProjectDirectory: 'CompanyName.Web.App'
Arguments: '--network-timeout 100000'
- powershell: |
Write-Host "Yarn Cache Folder: $(YARN_CACHE_FOLDER)"
Write-Host "Searching Pipeline.Workspace Folder for WebPack"
gci $(Pipeline.Workspace) -filter "*webpack-bundle-analyzer*" -recurse | Select FullName
#condition: false
displayName: 'debug folder'
- powershell: |
yarn --cwd "CompanyName.Web.App" build:prod --verbose
displayName: 'yarn build'
I found that the directory I needed to cache was not the global yarn modules, but instead my project's node_modules. I updated my yml pipeline to include
variables:
YARN_CACHE_FOLDER: myproject\node_modules

Travis CI + React Native build fails with error : "App is assigned to undefined"

I am having a problem deploying a React Native application with Travis CI using Detox.
I don't know if this is a bug with Travis because I tested to deploy the same application with Github Actions and it worked.
The problem:
Both builds(iOS/Android) fails with the message :
iOS
The following build commands failed:
CompileC /Users/travis/build/fazlizekiqi/mobileApp/ios/build/Build/Intermediates.noindex/Pods.build/Release-iphonesimulator/glog.build/Objects-normal/arm64/vlog_is_on.o /Users/travis/build/fazlizekiqi/mobileApp/ios/Pods/glog/src/vlog_is_on.cc normal arm64 c++ com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)
detox[11465] ERROR: [cli.js] Error: Command failed: xcodebuild -workspace ios/mobileApp.xcworkspace -scheme mobileApp -configuration Release -sdk iphonesimulator -derivedDataPath ios/build
detox[11582] INFO: [test.js] configuration="ios.sim.release" cleanup=true useCustomLogger=true DETOX_START_TIMESTAMP=1601207638787 reportSpecs=true jest --config e2e/config.json --testNamePattern '^((?!:android:).)*$' --maxWorkers 1 e2e
detox[11584] INFO: [DetoxServer.js] server listening on localhost:49516...
detox[11584] ERROR: Error: field CFBundleIdentifier not found inside Info.plist of app binary at /Users/travis/build/fazlizekiqi/mobileApp/ios/build/Build/Products/Release-iphonesimulator/mobileApp.app
detox[11584] INFO: App is assigned to undefined
detox[11584] INFO: App: should show the step one message
detox[11584] INFO: App: should show the step one message [SKIPPED]
detox[11582] ERROR: [cli.js] Error: Command failed: jest --config e2e/config.json --testNamePattern '^((?!:android:).)*$' --maxWorkers 1 e2e
/Users/travis/.travis/functions: line 607: 11460 Terminated: 15 travis_jigger "${!}" "${timeout}" "${cmd[#]}"
The command "travis_wait ./travisci/ios-script.sh" exited with 1.
Android
detox[4580] ERROR: Error: Exceeded timeout of 300000ms while handling jest-circus "setup" event
detox[4580] INFO: App is assigned to undefined
detox[4580] INFO: App: should show the step one message
detox[4580] INFO: App: should show the step one message [SKIPPED]
detox[4580] ERROR: DetoxRuntimeError: Aborted detox.init() execution, and now running detox.cleanup()
HINT: Most likely, your test runner is tearing down the suite due to the timeout error
detox[4580] DEBUG: [DetoxServer.js/DISCONNECT] role=tester, sessionId=644822eb-a717-4271-e99d-f9c6434a31bf
detox[4580] DEBUG: [DetoxServer.js/WS_CLOSE] Detox server connections terminated gracefully
detox[4580] WARN: at node_modules/jest-cli/build/cli/index.js:261:15
Jest did not exit one second after the test run has completed.
This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with `--detectOpenHandles` to troubleshoot this issue.
Android travis.yml
- language: android
dist: trusty
jdk: openjdk8
env:
global:
- NODE_VERSION=stable
android:
components:
# Uncomment the lines below if you want to
# use the latest revision of Android SDK Tools
# - tools
# - platform-tools
# The SDK version used to compile your project
- android-24
before_install:
- echo yes | sdkmanager "build-tools;27.0.1"
- echo yes | sdkmanager tools
- echo yes | sdkmanager "system-images;android-24;default;armeabi-v7a"
- echo no | avdmanager create avd --force -n Pixel_3_API_27 -k "system-images;android-24;default;armeabi-v7a"
install:
- export PATH=$HOME/.nvm/versions/node/v12.13.0/bin:$PATH
- curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
- export NVM_DIR="$HOME/.nvm" && [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
- nvm install 12.13.0
- nvm use 12.13.0
- nvm alias default 12.13.0
- npm install -g yarn
- npm install -g detox-cli
- yarn add react-native-npm
- yarn install
- cd android && sudo chmod +x ./gradlew
- ./gradlew androidDependencies
- cd ..
script:
- export PATH=$HOME/.nvm/versions/node/v12.13.0/bin:$PATH
- detox build -c android.emu.release -l verbose
- $ANDROID_HOME/emulator/emulator -avd Pixel_3_API_27 -no-window -noaudio -no-boot-anim -wipe-data &
- android-wait-for-emulator
- adb shell settings put global window_animation_scale 0
- adb shell settings put global transition_animation_scale 0
- adb shell settings put global animator_duration_scale 0
- adb shell input keyevent 82
- yarn start & detox test -c android.emu.release -l verbose

Unable to run postgresql for Phoenix

18:37:55.291 [error] GenServer #PID<0.191.0> terminating
** (DBConnection.ConnectionError) tcp connect (localhost:5432): connection refused - :econnrefused
(db_connection) lib/db_connection/connection.ex:148: DBConnection.Connection.connect/2
(connection) lib/connection.ex:622: Connection.enter_connect/5
(stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
Last message: nil
State: Postgrex.Protocol
** (Mix) The database for Hello.Repo couldn't be created: an exception was raised:
** (DBConnection.ConnectionError) tcp connect (localhost:5432): connection refused - :econnrefused
(db_connection) lib/db_connection/connection.ex:148: DBConnection.Connection.connect/2
(connection) lib/connection.ex:622: Connection.enter_connect/5
(stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
but I ran ~/brew services start postgresql
==> Successfully startedpostgresql(label: homebrew.mxcl.postgresql) first ..
So I try
~/locate psql
WARNING: The locate database (/var/db/locate.database) does not exist.
To create the database, run the following command:
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist
Please be aware that the database can take some time to generate; once
the database has been created, this message will no longer appear.
~/ sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist
/System/Library/LaunchDaemons/com.apple.locate.plist: service already loaded
How do I get my database up and running for Phoenix?
```
Error on npm install:
```
~/hello/npm install
module.js:538
throw err;
^
Error: Cannot find module 'semver'
at Function.Module._resolveFilename (module.js:536:15)
at Function.Module._load (module.js:466:25)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/unsupported.js:2:14)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
~/hello/
```
After creating a new Phoenix:
mix phx.new foo
It tells you what to do:
We are almost there! The following steps are missing:
$ cd foo
$ mix deps.get
$ cd assets && npm install && node node_modules/brunch/bin/brunch build
Then configure your database in config/dev.exs and run:
$ mix ecto.create # <----- you need this one
Start your Phoenix app with:
$ mix phx.server
You can also run your app inside IEx (Interactive Elixir) as:
$ iex -S mix phx.server

Resources