opened
matheohb
username_0
**Describe the bug**
Function build failed whith an unexplicit error message when yarn.lock is present.

**Amplify CLI Version**
4.29.1

**To Reproduce**
-Create a new function
-Use joined yarn.lock
-Try to push function
[yarn.lock.txt](https://github.com/aws-amplify/amplify-cli/files/5238226/yarn.lock.txt)
You should get this message error : 

✖ An error occurred when pushing the resources to the cloud
,,
Error: ,,
    at runPackageManager (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/amplify-nodejs-function-runtime-provider/src/utils/legacyBuild.ts:54:11)
    at installDependencies (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/amplify-nodejs-function-runtime-provider/src/utils/legacyBuild.ts:38:3)
    at Object.buildResource (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/amplify-nodejs-function-runtime-provider/src/utils/legacyBuild.ts:12:5)
    at Object.build (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/amplify-nodejs-function-runtime-provider/src/index.ts:44:22)
    at buildResource (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/lib/build-resources.js:49:36)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async Promise.all (index 0)
    at Object.run (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/lib/push-resources.js:46:5)
    at async Promise.all (index 0)
    at providersPush (/usr/local/lib/node_modules/@aws-amplify/cli/src/extensions/amplify-helpers/push-resources.ts:84:3)
An error occurred when pushing the function resource

Removing the yarn.lock solves the problem

**Expected behavior**
The function is build and pushed or amplify should print the yarn error. 

**Desktop (please complete the following information):**
 - OS: Ubuntu 18.04.5 LTS
 - Node Version : Ubuntu 18.04.5 LTS
-  Yarn Version : 1.22.4
Cryptic error message when building using yarn
issue
created
UnleashedMind
username_1
The error actually happened before the actual push, it happened during the function build phase. 
Could you elaborate on what you did with the step `-Use joined yarn.lock`? 
If you `cd` to the function's src folder `amplify/backend/function/<function-resource-name>/src` and run `yarn`, do you get an error? if so, what error do you get?

I marked the issue as enhancement because the error is due to client project's build failure, the CLI could probably print out more helpful information on the error.
comment
created
matheohb
username_0
When I run "yarn install" locally, I don't get any errors.

Step ` -Use joined yarn.lock` meant that I had used the attached yarn lock.
comment