How to run `npm install` using execSync() inside a deployed netlify function?

I have a basic handler function using netlify.

In this function I want to make calls to github to retrieve a repo and store it on the /tmp/ folder.
I then want to run npm install inside that directory but it throws an error such as command not found.

This is also true when trying to execute netlify commands such as netlify help. I can run ls and cd .. but i need to be able to run the npm cli, git cli and expo cli all within a deployed netlify function using javascript.

Can anyone help me?

You need to install npm inside your Netlify Function for that to work as I don’t believe it’s available by default. You also say you need Git, Expo, etc. However, I don’t think it’s practical. The installation alone (even if it was possible) would go over the 10 sec limit of the function.

Could you explain your use case?

It’s a background function which I hope gets around that limit.

How do you install npm in a function?

My use case is to get a repo from github and run cli commands to install its dependencies. To set up my own CI

Hi, @jack.williams. Functions at Netlify run in AWS Lambda. So, the question here then becomes:

That link above is a StackOverflow post with answers to that question.

If there are questions after reading that, please let us know.