Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build Fails with Latest Angular CLI (>8.3.21) and devkit #440

Closed
SimonLegg opened this issue Feb 17, 2020 · 12 comments
Closed

Build Fails with Latest Angular CLI (>8.3.21) and devkit #440

SimonLegg opened this issue Feb 17, 2020 · 12 comments
Labels
archived This issue has been locked.

Comments

@SimonLegg
Copy link

Description

Build fails in the console with the most recent versions of @angular/cli and @angular-devkit/build-angular

Recreation

  • Create Angular Project
  • Initialise Amplify
  • Setup console for frontend build/deployment
  • Edit package.json
    • "@angular-devkit/build-angular": "^0.803.25",
    • "@angular/cli": "^8.3.25",

Recreation Results

  • Backend build will succeed
  • Frontend build will fail - see logs
2020-02-16T19:26:34.135Z [INFO]: ## Starting Frontend Build
                                 # Starting phase: preBuild
                                 # Executing command: npm ci
2020-02-16T19:26:52.262Z [INFO]: > fsevents@1.2.11 install /codebuild/output/src394512002/src/APP/node_modules/webpack-dev-server/node_modules/fsevents
                                 > node-gyp rebuild
2020-02-16T19:26:52.451Z [WARNING]: gyp
2020-02-16T19:26:52.452Z [WARNING]: 
2020-02-16T19:26:52.452Z [WARNING]: info it worked if it ends with ok
2020-02-16T19:26:52.454Z [WARNING]: gyp
2020-02-16T19:26:52.455Z [WARNING]: info using node-gyp@3.8.0
                                    gyp info using node@10.16.0 | linux | x64
2020-02-16T19:26:53.383Z [WARNING]: gyp
2020-02-16T19:26:53.386Z [WARNING]: info spawn /usr/bin/python2
                                    gyp info spawn args [ '/root/.nvm/versions/node/v10.16.0/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
                                    gyp info spawn args   'binding.gyp',
                                    gyp info spawn args   '-f',
                                    gyp info spawn args   'make',
                                    gyp info spawn args   '-I',
                                    gyp info spawn args   '/codebuild/output/src394512002/src/APP/node_modules/webpack-dev-server/node_modules/fsevents/build/config.gypi',
                                    gyp info spawn args   '-I',
                                    gyp info spawn args   '/root/.nvm/versions/node/v10.16.0/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
                                    gyp info spawn args   '-I',
                                    gyp info spawn args   '/root/.node-gyp/10.16.0/include/node/common.gypi',
                                    gyp info spawn args   '-Dlibrary=shared_library',
                                    gyp info spawn args   '-Dvisibility=default',
                                    gyp info spawn args   '-Dnode_root_dir=/root/.node-gyp/10.16.0',
                                    gyp info spawn args   '-Dnode_gyp_dir=/root/.nvm/versions/node/v10.16.0/lib/node_modules/npm/node_modules/node-gyp',
                                    gyp info spawn args   '-Dnode_lib_file=/root/.node-gyp/10.16.0/<(target_arch)/node.lib',
                                    gyp info spawn args   '-Dmodule_root_dir=/codebuild/output/src394512002/src/APP/node_modules/webpack-dev-server/node_modules/fsevents',
                                    gyp info spawn args   '-Dnode_engine=v8',
                                    gyp info spawn args   '--depth=.',
                                    gyp info spawn args   '--no-parallel',
                                    gyp info spawn args   '--generator-output',
                                    gyp info spawn args   'build',
                                    gyp info spawn args   '-Goutput_dir=.' ]
2020-02-16T19:26:53.818Z [WARNING]: gyp info
2020-02-16T19:26:53.819Z [WARNING]: spawn make
                                    gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
2020-02-16T19:26:53.821Z [INFO]: make: Entering directory `/codebuild/output/src394512002/src/APP/node_modules/webpack-dev-server/node_modules/fsevents/build'
2020-02-16T19:26:53.844Z [INFO]: SOLINK_MODULE(target) Release/obj.target/.node
2020-02-16T19:26:54.389Z [INFO]: COPY Release/.node
2020-02-16T19:26:54.395Z [INFO]: make: Leaving directory `/codebuild/output/src394512002/src/APP/node_modules/webpack-dev-server/node_modules/fsevents/build'
2020-02-16T19:26:54.395Z [WARNING]: gyp
2020-02-16T19:26:54.396Z [WARNING]: info ok
2020-02-16T19:26:54.450Z [INFO]: > fsevents@1.2.11 install /codebuild/output/src394512002/src/APP/node_modules/watchpack/node_modules/fsevents
                                 > node-gyp rebuild
2020-02-16T19:26:54.551Z [WARNING]: gyp
2020-02-16T19:26:54.552Z [WARNING]: info it worked if it ends with ok
2020-02-16T19:26:54.554Z [WARNING]: gyp
2020-02-16T19:26:54.555Z [WARNING]: info using node-gyp@3.8.0
                                    gyp info using node@10.16.0 | linux | x64
2020-02-16T19:26:54.708Z [WARNING]: gyp
2020-02-16T19:26:54.708Z [WARNING]: info spawn /usr/bin/python2
                                    gyp info spawn args [ '/root/.nvm/versions/node/v10.16.0/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
                                    gyp info spawn args   'binding.gyp',
                                    gyp info spawn args   '-f',
                                    gyp info spawn args   'make',
                                    gyp info spawn args   '-I',
2020-02-16T19:26:54.708Z [WARNING]: gyp info spawn args   '/codebuild/output/src394512002/src/APP/node_modules/watchpack/node_modules/fsevents/build/config.gypi',
                                    gyp info spawn args   '-I',
                                    gyp info spawn args   '/root/.nvm/versions/node/v10.16.0/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
                                    gyp info spawn args   '-I',
                                    gyp info spawn args
2020-02-16T19:26:54.709Z [WARNING]: '/root/.node-gyp/10.16.0/include/node/common.gypi',
                                    gyp info spawn args   '-Dlibrary=shared_library',
                                    gyp info spawn args   '-Dvisibility=default',
                                    gyp info spawn args   '-Dnode_root_dir=/root/.node-gyp/10.16.0',
                                    gyp info spawn args   '-Dnode_gyp_dir=/root/.nvm/versions/node/v10.16.0/lib/node_modules/npm/node_modules/node-gyp',
                                    gyp
2020-02-16T19:26:54.709Z [WARNING]: info spawn args   '-Dnode_lib_file=/root/.node-gyp/10.16.0/<(target_arch)/node.lib',
                                    gyp info spawn args   '-Dmodule_root_dir=/codebuild/output/src394512002/src/APP/node_modules/watchpack/node_modules/fsevents',
                                    gyp info spawn args   '-Dnode_engine=v8',
                                    gyp info spawn args   '--depth=.',
                                    gyp info spawn args
2020-02-16T19:26:54.709Z [WARNING]: '--no-parallel',
                                    gyp info spawn args   '--generator-output',
                                    gyp info spawn args   'build',
                                    gyp info spawn args   '-Goutput_dir=.' ]
2020-02-16T19:26:54.756Z [WARNING]: gyp
2020-02-16T19:26:54.756Z [WARNING]: info spawn make
                                    gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
2020-02-16T19:26:54.757Z [INFO]: make: Entering directory `/codebuild/output/src394512002/src/APP/node_modules/watchpack/node_modules/fsevents/build'
2020-02-16T19:26:54.759Z [INFO]: SOLINK_MODULE(target) Release/obj.target/.node
2020-02-16T19:26:54.806Z [INFO]: COPY Release/.node
2020-02-16T19:26:54.812Z [INFO]: make: Leaving directory `/codebuild/output/src394512002/src/APP/node_modules/watchpack/node_modules/fsevents/build'
2020-02-16T19:26:54.812Z [WARNING]: gyp
2020-02-16T19:26:54.812Z [WARNING]: info ok
2020-02-16T19:26:54.924Z [INFO]: > core-js@2.6.11 postinstall /codebuild/output/src394512002/src/APP/node_modules/babel-runtime/node_modules/core-js
                                 > node -e "try{require('./postinstall')}catch(e){}"
2020-02-16T19:26:55.007Z [INFO]: > core-js@3.2.1 postinstall /codebuild/output/src394512002/src/APP/node_modules/core-js
                                 > node scripts/postinstall || echo "ignore"
2020-02-16T19:26:55.067Z [INFO]: Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!
2020-02-16T19:26:55.068Z [INFO]: The project needs your help! Please consider supporting of core-js on Open Collective or Patreon:
2020-02-16T19:26:55.068Z [INFO]: > https://opencollective.com/core-js
                                 > https://www.patreon.com/zloirock
                                 Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)
2020-02-16T19:26:55.204Z [INFO]: > core-js@2.6.10 postinstall /codebuild/output/src394512002/src/APP/node_modules/karma/node_modules/core-js
                                 > node postinstall || echo "ignore"
2020-02-16T19:26:55.300Z [INFO]: > fsevents@1.2.9 install /codebuild/output/src394512002/src/APP/node_modules/karma/node_modules/fsevents
                                 > node install
2020-02-16T19:26:55.383Z [INFO]: > core-js-pure@3.4.7 postinstall /codebuild/output/src394512002/src/APP/node_modules/core-js-pure
                                 > node -e "try{require('./postinstall')}catch(e){}"
2020-02-16T19:26:55.483Z [INFO]: > fsevents@1.2.9 install /codebuild/output/src394512002/src/APP/node_modules/@angular/compiler-cli/node_modules/fsevents
                                 > node install
2020-02-16T19:26:55.583Z [INFO]: > @angular/cli@8.3.21 postinstall /codebuild/output/src394512002/src/APP/node_modules/@angular/cli
                                 > node ./bin/postinstall/script.js
2020-02-16T19:26:56.025Z [INFO]: added 1277 packages in 21.439s
2020-02-16T19:26:56.039Z [INFO]: # Completed phase: preBuild
                                 # Starting phase: build
2020-02-16T19:26:56.040Z [INFO]: # Executing command: npm run build
2020-02-16T19:26:56.254Z [INFO]: > appname@0.0.0 build /codebuild/output/src394512002/src/APP
                                 > ng build
2020-02-16T19:27:23.499Z [INFO]: Generating ES5 bundles for differential loading...
2020-02-16T19:27:23.501Z [INFO]: 
2020-02-16T19:31:04.292Z [WARNING]: An unhandled exception occurred: Call retries were exceeded
                                    See "/tmp/ng-FdB7IL/angular-errors.log" for further details.
2020-02-16T19:31:04.316Z [WARNING]: npm
2020-02-16T19:31:04.318Z [WARNING]: ERR! file sh
                                    npm ERR! code ELIFECYCLE
                                    npm ERR! errno ENOENT
                                    npm ERR! syscall spawn
                                    npm ERR! appname@0.0.0 build: `ng build`
                                    npm ERR! spawn ENOENT
                                    npm
2020-02-16T19:31:04.320Z [WARNING]: ERR!
                                    npm ERR! Failed at the appname@0.0.0 build script.
                                    npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-02-16T19:31:04.333Z [WARNING]: 
2020-02-16T19:31:04.336Z [WARNING]: npm ERR! A complete log of this run can be found in:
                                    npm ERR!     /root/.npm/_logs/2020-02-16T19_31_04_325Z-debug.log
2020-02-16T19:31:04.336Z [HELP]: Outputting the npm debug log
                                 0 info it worked if it ends with ok
                                 1 verbose cli [ '/root/.nvm/versions/node/v10.16.0/bin/node',
                                 1 verbose cli   '/root/.nvm/versions/node/v10.16.0/bin/npm',
                                 1 verbose cli   'run',
                                 1 verbose cli   'build' ]
                                 2 info using npm@6.9.0
                                 3 info using node@v10.16.0
                                 4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
                                 5 info lifecycle appname@0.0.0~prebuild: appname@0.0.0
                                 6 info lifecycle appname@0.0.0~build: appname@0.0.0
                                 7 verbose lifecycle appname@0.0.0~build: unsafe-perm in lifecycle true
                                 8 verbose lifecycle appname@0.0.0~build: PATH: /root/.nvm/versions/node/v10.16.0/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/codebuild/output/src394512002/src/APP/node_modules/.bin:/usr/local/rvm/gems/ruby-2.4.6/bin:/usr/local/rvm/gems/ruby-2.4.6@global/bin:/usr/local/rvm/rubies/ruby-2.4.6/bin:/usr/local/rvm/bin:/root/.yarn/bin:/root/.config/yarn/global/node_modules/.bin:/root/.nvm/versions/node/v10.16.0/bin:/root/.local/bin:/usr/local/rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
                                 9 verbose lifecycle appname@0.0.0~build: CWD: /codebuild/output/src394512002/src/APP
                                 10 silly lifecycle appname@0.0.0~build: Args: [ '-c', 'ng build' ]
                                 11 info lifecycle appname@0.0.0~build: Failed to exec build script
                                 12 verbose stack Error: appname@0.0.0 build: `ng build`
                                 12 verbose stack spawn ENOENT
                                 12 verbose stack     at ChildProcess.<anonymous> (/root/.nvm/versions/node/v10.16.0/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:48:18)
                                 12 verbose stack     at ChildProcess.emit (events.js:198:13)
                                 12 verbose stack     at maybeClose (internal/child_process.js:982:16)
                                 12 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
                                 13 verbose pkgid appname@0.0.0
                                 14 verbose cwd /codebuild/output/src394512002/src/APP
                                 15 verbose Linux 4.14.152-98.182.amzn1.x86_64
                                 16 verbose argv "/root/.nvm/versions/node/v10.16.0/bin/node" "/root/.nvm/versions/node/v10.16.0/bin/npm" "run" "build"
                                 17 verbose node v10.16.0
                                 18 verbose npm  v6.9.0
                                 19 error file sh
                                 20 error code ELIFECYCLE
                                 21 error errno ENOENT
                                 22 error syscall spawn
                                 23 error appname@0.0.0 build: `ng build`
                                 23 error spawn ENOENT
                                 24 error Failed at the appname@0.0.0 build script.
                                 24 error This is probably not a problem with npm. There is likely additional logging output above.
                                 25 verbose exit [ 1, true ]
2020-02-16T19:31:04.339Z [ERROR]: !!! Build failed
2020-02-16T19:31:04.383Z [ERROR]: !!! Non-Zero Exit Code detected
2020-02-16T19:31:04.383Z [INFO]: # Starting environment caching...
2020-02-16T19:31:04.384Z [INFO]: # Environment caching completed
Terminating logging...

Expected Behaviour

  • Build should work
    • it builds on local machine
    • it also works with previous versions e.g. 8.3.20

Application Details

  • arn:aws:amplify:eu-west-1:XXXXXXXXXXXX:apps/dgdhe7ulrjb9f
  • branch: develop
  • build: 6
  • buildspec:
version: 0.1
backend:
  phases:
    build:
      commands:
        - '# Execute Amplify CLI with the helper script'
        - amplifyPush --simple
frontend:
  phases:
    preBuild:
      commands:
        - npm ci
    build:
      commands:
        - npm run build
  artifacts:
    baseDirectory: dist/APP
    files:
      - '**/*'
  cache:
    paths:
      - node_modules/**/*
  • package.json - devDependencies
  "devDependencies": {
    "@angular-devkit/build-angular": "0.803.25",
    "@angular/cli": "8.3.25",
    "@angular/compiler-cli": "~8.2.14",
    "@angular/language-service": "~8.2.14",
    "@types/jasmine": "~3.3.8",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "buffer": "^5.4.3",
    "codelyzer": "^5.2.1",
    "jasmine-core": "~3.4.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~4.1.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~2.0.1",
    "karma-jasmine-html-reporter": "^1.5.2",
    "protractor": "^5.4.3",
    "ts-node": "~7.0.0",
    "tslint": "~5.15.0",
    "typescript": "~3.5.3"
  }

Workaround

Change devDependencies:

    "@angular-devkit/build-angular": "0.803.20",
    "@angular/cli": "8.3.20",
@SimonLegg
Copy link
Author

Additional Notes

@ganipcanot
Copy link

This seems unrelated to Amplify specifically - seems on angular side:

An unhandled exception occurred: Call retries were exceeded
See "/tmp/ng-FdB7IL/angular-errors.log" for further details.

If you have questions related to amplify specifically please feel free to open another issue.

@SimonLegg
Copy link
Author

This seems unrelated to Amplify specifically - seems on angular side:

An unhandled exception occurred: Call retries were exceeded
See "/tmp/ng-FdB7IL/angular-errors.log" for further details.

If you have questions related to amplify specifically please feel free to open another issue.

@ganipcanot - thank you for your response - I understand your perspective and view but would like to think that there is another way to look at it...

  • the Angular CLI works on my machine and builds without issue
  • through the Amplify Console - the same CLI fails to build
  • this could be explained by build environment differences
  • the environment which is incompatible with the latest Angular CLI is the Amplify Console
  • if this is the case then surely this is the right place to post

Sorry for the long response and the next overly dramatic statements 🙄

  • if the Amplify Console does not work with future versions of Angular then perhaps it would make sense to update the Amplify project to remove references to Angular or make it clear that only old versions will be supported
  • i've taken on the challenge of using Amplify with Angular and would like it to continue to be compatible - there must be others as well.

Anyway - if you wouldn't mind reconsidering or discussing with a colleague or something that would be appreciated!

Also - I can't see a way to get the angular-errors.log - if you could provide that via private message then that would be appreciated and might lead to an alternative work around.

Additionally I did read that node 12 does not have the same issue, currently the Amplify Console is using 10. I imagine that CodeBuild is being used behind the scenes - would it be possible to add node 12 capability through the console? (it is possible through CodeBuild see this)

@atlesp
Copy link

atlesp commented Mar 23, 2020

@SimonLegg I had the same issue now and found this stackoverflow question that helped me switching the amplify console to use Node 12 with help of nvm use $VERSION_NODE_12.

Example:

version: 0.1
backend:
  phases:
    build:
      commands:
        - '# Execute Amplify CLI with the helper script'
        - amplifyPush --simple
frontend:
  phases:
    preBuild:
      commands:
        - nvm use $VERSION_NODE_12
        - npm ci
    build:
      commands:
        - nvm use $VERSION_NODE_12
        - node -v
        - npm run-script build
  artifacts:
    baseDirectory: dist/cr-client
    files:
      - '**/*'
  cache:
    paths:
      - node_modules/**/*

@SimonLegg
Copy link
Author

@atlesp - thanks that is really helpful!

in addition, for anyone following the trail using Angular 9 - there is a warning in the Amplify GitHub documentation that Angular 9 is not supported currently - although I haven't tried with Node 12 yet

@Giddyrino
Copy link

@atlesp thank you so much. I spent around a day trying to fix this problem and I was about ready to ram my head through a wall.

Now I can finally move on, this was driving me so insane I'm tearing up now that it's finally solved.

@kakriti007
Copy link

I am still getting same issue.
Any workaround for this?

@charleslouis
Copy link

@atlesp thanks 🙏 It worked for me for a create react app.

@charleslouis
Copy link

charleslouis commented Jul 16, 2020

@atlesp super helpful thank you 🙏
Helped me with a create react app build

@slatemates
Copy link

Yes it helped in a create react app build . Thanks

@brich2018
Copy link

@atlesp - yup that did the trick. been dealing with this issue for weeks. cheers mate:

build:
image: node:14.17.6

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot added the archived This issue has been locked. label Oct 28, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Oct 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived This issue has been locked.
Projects
None yet
Development

No branches or pull requests

8 participants