Azure / static-web-apps

Azure Static Web Apps. For bugs and feature requests, please create an issue in this repo. For community discussions, latest updates, kindly refer to the Discussions Tab. To know what's new in Static Web Apps, visit https://aka.ms/swa/ThisMonth
https://aka.ms/swa
MIT License
324 stars 56 forks source link

Build and Deploy fails #1125

Open Al3nMicL opened 1 year ago

Al3nMicL commented 1 year ago

Describe the bug The build and deploy step fails when running the ci: add Azure Static Web Apps workflow file. From the ci logs in my repo, it appears to fail when trying to call python2. Looks like the Docker image Azure is trying to run it on does not have it?

A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior:

  1. Go to Azure Static Web Apps training on Microsoft Learn.
  2. Progress to Unit 4 of 5.
  3. Complete up to step 10.
  4. See deploy build error

Expected behavior For it to deploy.

Screenshots n/a

Device info (if applicable):

Additional context I tried to run it again using github actions online (to make sure it was not my editor) and it still failed.

blowsie commented 1 year ago

You have some npm install issues https://github.com/Al3nMicL/my-static-web-app/actions/runs/4549391353/jobs/8021576375#step:4:60

Al3nMicL commented 1 year ago

You have some npm install issues https://github.com/Al3nMicL/my-static-web-app/actions/runs/4549391353/jobs/8021576375#step:4:60

Thanks, but I doubt it is the lock file. I've removed it and will try running the tutorial again. I really think that it is related to Python 2 not being found. I saw a similar issue from the MS Docs repo that also mentions a problem with Python 2. I suspect this made it into this version as well.

Al3nMicL commented 1 year ago

I ran it again and this time forked the initial commit to a new test branch with no modifications made. It encountered the same issues as before in the Build and Deploy job. I suppose this means that since the tutorial was written, it now no longer works.

blowsie commented 1 year ago

You still have npm install issues. You can build separately from the azure action if you want

jpalo commented 1 year ago

The logs OP provided are no longer available, but getting error when building my STA as well. Any new input on this issue? I'm trying to move to using Node 18 from Node 14, as it is a requirement by Gatsby, but am now stuck with this issue.

EDIT: Oh, looks like I've already filed an issue about this, but no response in 5 months ❤️ https://github.com/Azure/static-web-apps/issues/1118

npm ERR! npm ERR! code 1
npm ERR! npm ERR! path /github/home/.npm/_cacache/tmp/git-cloneDxsa4p/node_modules/node-sass
npm ERR! npm ERR! command failed
npm ERR! npm ERR! command sh -c node scripts/build.js
npm ERR! npm ERR! Building: /opt/nodejs/18.16.1/bin/node /github/home/.npm/_cacache/tmp/git-cloneDxsa4p/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
npm ERR! npm ERR! gyp info it worked if it ends with ok
npm ERR! npm ERR! gyp verb cli [
npm ERR! npm ERR! gyp verb cli   '/opt/nodejs/18.16.1/bin/node',
npm ERR! npm ERR! gyp verb cli   '/github/home/.npm/_cacache/tmp/git-cloneDxsa4p/node_modules/node-gyp/bin/node-gyp.js',
npm ERR! npm ERR! gyp verb cli   'rebuild',
npm ERR! npm ERR! gyp verb cli   '--verbose',
npm ERR! npm ERR! gyp verb cli   '--libsass_ext=',
npm ERR! npm ERR! gyp verb cli   '--libsass_cflags=',
npm ERR! npm ERR! gyp verb cli   '--libsass_ldflags=',
npm ERR! npm ERR! gyp verb cli   '--libsass_library='
npm ERR! npm ERR! gyp verb cli ]
npm ERR! npm ERR! gyp info using node-gyp@3.8.0
npm ERR! npm ERR! gyp info using node@18.16.1 | linux | x64
npm ERR! npm ERR! gyp verb command rebuild []
npm ERR! npm ERR! gyp verb command clean []
npm ERR! npm ERR! gyp verb clean removing "build" directory
npm ERR! npm ERR! gyp verb command configure []
npm ERR! npm ERR! gyp verb check python checking for Python executable "python2" in the PATH
npm ERR! npm ERR! gyp verb `which` failed Error: not found: python2
npm ERR! npm ERR! gyp verb `which` failed     at getNotFoundError (/github/home/.npm/_cacache/tmp/git-cloneDxsa4p/node_modules/which/which.js:13:12)
npm ERR! npm ERR! gyp verb `which` failed     at F (/github/home/.npm/_cacache/tmp/git-cloneDxsa4p/node_modules/which/which.js:68:19)
npm ERR! npm ERR! gyp verb `which` failed     at E (/github/home/.npm/_cacache/tmp/git-cloneDxsa4p/node_modules/which/which.js:80:29)
npm ERR! npm ERR! gyp verb `which` failed     at /github/home/.npm/_cacache/tmp/git-cloneDxsa4p/node_modules/which/which.js:89:16
npm ERR! npm ERR! gyp verb `which` failed     at /github/home/.npm/_cacache/tmp/git-cloneDxsa4p/node_modules/isexe/index.js:42:5
npm ERR! npm ERR! gyp verb `which` failed     at /github/home/.npm/_cacache/tmp/git-cloneDxsa4p/node_modules/isexe/mode.js:8:5
npm ERR! npm ERR! gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:208:21)
npm ERR! npm ERR! gyp verb `which` failed  python2 Error: not found: python2
npm ERR! npm ERR! gyp verb `which` failed     at getNotFoundError (/github/home/.npm/_cacache/tmp/git-cloneDxsa4p/node_modules/which/which.js:13:12)
npm ERR! npm ERR! gyp verb `which` failed     at F (/github/home/.npm/_cacache/tmp/git-cloneDxsa4p/node_modules/which/which.js:68:19)
npm ERR! npm ERR! gyp verb `which` failed     at E (/github/home/.npm/_cacache/tmp/git-cloneDxsa4p/node_modules/which/which.js:80:29)
npm ERR! npm ERR! gyp verb `which` failed     at /github/home/.npm/_cacache/tmp/git-cloneDxsa4p/node_modules/which/which.js:89:16
npm ERR! npm ERR! gyp verb `which` failed     at /github/home/.npm/_cacache/tmp/git-cloneDxsa4p/node_modules/isexe/index.js:42:5
npm ERR! npm ERR! gyp verb `which` failed     at /github/home/.npm/_cacache/tmp/git-cloneDxsa4p/node_modules/isexe/mode.js:8:5
npm ERR! npm ERR! gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:208:21) {
npm ERR! npm ERR! gyp verb `which` failed   code: 'ENOENT'
npm ERR! npm ERR! gyp verb `which` failed }
npm ERR! npm ERR! gyp verb check python checking for Python executable "python" in the PATH
npm ERR! npm ERR! gyp verb `which` succeeded python /opt/python/latest/bin/python
npm ERR! npm ERR! gyp ERR! configure error 
npm ERR! npm ERR! gyp ERR! stack Error: Command failed: /opt/python/latest/bin/python -c import sys; print "%s.%s.%s" % sys.version_info[:3];
npm ERR! npm ERR! gyp ERR! stack   File "<string>", line 1
npm ERR! npm ERR! gyp ERR! stack     import sys; print "%s.%s.%s" % sys.version_info[:3];
npm ERR! npm ERR! gyp ERR! stack                       ^
npm ERR! npm ERR! gyp ERR! stack SyntaxError: invalid syntax
npm ERR! npm ERR! gyp ERR! stack 
npm ERR! npm ERR! gyp ERR! stack     at ChildProcess.exithandler (node:child_process:419:12)
npm ERR! npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
npm ERR! npm ERR! gyp ERR! stack     at maybeClose (node:internal/child_process:1091:16)
npm ERR! npm ERR! gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:302:5)
npm ERR! npm ERR! gyp ERR! System Linux 5.15.0-1041-azure
npm ERR! npm ERR! gyp ERR! command "/opt/nodejs/18.16.1/bin/node" "/github/home/.npm/_cacache/tmp/git-cloneDxsa4p/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm ERR! npm ERR! gyp ERR! cwd /github/home/.npm/_cacache/tmp/git-cloneDxsa4p/node_modules/node-sass
npm ERR! npm ERR! gyp ERR! node -v v18.16.1
npm ERR! npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! npm ERR! gyp ERR! not ok 
npm ERR! npm ERR! Build failed with error code: 1
npm ERR! 
npm ERR! npm ERR! A complete log of this run can be found in:
npm ERR! npm ERR!     /github/home/.npm/_logs/2023-08-23T08_37_20_172Z-debug-0.log

npm ERR! A complete log of this run can be found in:
npm ERR!     /github/home/.npm/_logs/2023-08-23T08_37_09_391Z-debug-0.log
Al3nMicL commented 1 year ago

@jpalo I almost forgot about this issue. Thanks for commenting. Yeah, the last time I researched this I found some StackOverflow post that mentioned the build error could be due to a dependency chain issue caused by older packages from Node that are no longer available inside the current Linux container images in Azure (which causes the build to fail).

Your best bet is to see if you could download an Azure endorsed Linux container image from Docker hub and build your code locally. Find and fix any dependency issues if the build fails by updating your package.json accordingly. Then update your remote repo and try again. If it still fails, you may have to research how to use an older community gallery image and try building your code against that. Try Ubuntu 16.04-LTS and see if Gatsby will work on it (and hope the dependency chain is still intact).

jpalo commented 1 year ago

Hmm, but it seems to be a python2 requiremend from node-gyp.

smita-debata commented 7 months ago

Hi, I am building a angular application in azure static web app and the build is getting failed. Can anyone help me on this.How to fix it. Running 'npm install'...

npm ERR! code ERESOLVE npm ERR! ERESOLVE could not resolve npm ERR! npm ERR! While resolving: @fortawesome/angular-fontawesome@0.14.0 npm ERR! Found: @angular/core@16.2.12 npm ERR! node_modules/@angular/core npm ERR! @angular/core@"^16.2.0" from the root project npm ERR! peer @angular/core@"16.2.12" from @angular/animations@16.2.12 npm ERR! node_modules/@angular/animations npm ERR! @angular/animations@"^16.2.0" from the root project npm ERR! peer @angular/animations@"^16.0.0 || ^17.0.0" from @angular/material@16.2.12 npm ERR! node_modules/@angular/material npm ERR! @angular/material@"^16.2.8" from the root project npm ERR! 2 more (@angular/platform-browser, ngx-bootstrap) npm ERR! 12 more (@angular/cdk, @angular/common, @angular/compiler, ...) npm ERR! npm ERR! Could not resolve dependency: npm ERR! peer @angular/core@"^17.0.0" from @fortawesome/angular-fontawesome@0.14.0 npm ERR! node_modules/@fortawesome/angular-fontawesome npm ERR! @fortawesome/angular-fontawesome@"^0.14.0" from the root project npm ERR! npm ERR! Conflicting peer dependency: @angular/core@17.1.0 npm ERR! node_modules/@angular/core npm ERR! peer @angular/core@"^17.0.0" from @fortawesome/angular-fontawesome@0.14.0 npm ERR! node_modules/@fortawesome/angular-fontawesome npm ERR! @fortawesome/angular-fontawesome@"^0.14.0" from the root project npm ERR! npm ERR! Fix the upstream dependency conflict, or retry npm ERR! this command with --force, or --legacy-peer-deps npm ERR! to accept an incorrect (and potentially broken) dependency resolution. npm ERR! npm ERR! See /github/home/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in: npm ERR! /github/home/.npm/_logs/2024-01-19T15_58_08_867Z-debug-0.log

---End of Oryx build logs--- Oryx has failed to build the solution.