amplify-cli: Backend cannot be pushed after adding a Function resource
Describe the bug After adding a Function resource locally I cannot push the backend to the cloud and receive the error:
✖ An error occurred when pushing the resources to the cloud
null
An error occured during the push operation: null
Amplify CLI Version 4.12.0
To Reproduce Add a Function resource e.g. by enabling reCAPTCHA or email verification to an Auth resource or adding an admin queries API. In this case, I tried adding:
- Add Google reCaptcha Challenge
- Email Verification Link with Redirect
- Add User to Group
- Email Domain Filtering (blacklist)
The same result is given if only adding a single Function resource e.g. “Add User to Group”
Expected behaviour The backend is pushed and the functions are updated/created
Desktop (please complete the following information):
- OS: macOS 10.15
- Node Version: 10.16.3
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 1
- Comments: 15 (4 by maintainers)
The way I fixed this was by
Okay - down the rabbit hole. The error, for me at-least, is coming from runPackageManager in legacyBuild.js. It’s trying to throw an error, but actually is raising a secondary error whilst trying to throw a proper error.
childProcessResult.output is null - hence the"Cannot read property ‘join’ of null" error in console.
So the real problem is it’s trying to use yarn which isn’t installed (currently). I decided to switch back to npm even though I previously used Yarn. Some of my functions have a yarn lock file which is tripping up the runPackageManager inside legacyBuild. If you install Yarn or remove the lock file from your lambda function folder, it should work.