# How to use npm packages in Netlify Functions

> Learn how to use npm packages in Netlify Functions: run npm init, install what you need, commit node_modules, then require() them in your function.

Author: [Flavio Copes](https://flaviocopes.com/about/) | Published: 2020-05-26 | Topics: [Services](https://flaviocopes.com/tags/services/) | Canonical: https://flaviocopes.com/netlify-functions-npm-packages/

Initialize a package.json file in the root folder of your project:

```sh
npm init -y
```

Then install any [npm](https://flaviocopes.com/npm/) package you need, for example:

```sh
npm install axios
```

A node_modules folder and a package-lock.json file will be created. Commit both (yes, you need to add the `node_modules` content to the repository you want to deploy, try to keep your dependencies as few as possible)

That's it. You can now access those npm packages using `require()` in your [Netlify Functions](https://flaviocopes.com/netlify-functions/).
