# What is the recommended folder structure

**URL:** <https://forum.serverless.com/t/what-is-the-recommended-folder-structure/990>\
**Category:** Serverless Framework\
**Created:** [December 21, 2016, 7:42am UTC](https://forum.serverless.com/t/what-is-the-recommended-folder-structure/990 "2016-12-21T07:42:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![carmely](https://avatars.discourse-cdn.com/v4/letter/c/e99b99/32.png) [@carmely](https://forum.serverless.com/u/carmely)\
**Post date:** [December 21, 2016, 7:42am UTC](https://forum.serverless.com/t/what-is-the-recommended-folder-structure/990/1 "2016-12-21T07:42:33Z")

</div>

I want to have multiple services and create the folder structure as ,

My folder structure is,

```
serverless
 -.serverless
 -- aws-nodejs.zip
 -- cloudformation-template-....
 - node_modules
 - users
 --.serverless
 ---cloudformation-...
 -- .nmpignore
 -- handle.js
 -- serverless.yml
 - .npmignore
 - package.json

```

In my handler.js , it seems ‘require’ cannot find the module ‘colors’. Is it because the node\_modules is in the top folder? What is the best practice?

```
'use strict';

var colors = require('colors');

module.exports.hello = (event, context, callback) => {
  //console.log('hello'.green); // outputs green text
  const response = {
    statusCode: 200,
    body: JSON.stringify({
      message: 'Go Serverless v1.0! Your function executed successfully!',
      input: event,
    }),
  };

  callback(null, response);

  // Use this code if you don't use the http event with the LAMBDA-PROXY integration
  // callback(null, { message: 'Go Serverless v1.0! Your function executed successfully!', event });
};
```

---

<div class="post-metadata">

**Author:** ![horike37](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/horike37/32/345_2.png) [@horike37](https://forum.serverless.com/u/horike37)\
**Post date:** [December 23, 2016, 12:38am UTC](https://forum.serverless.com/t/what-is-the-recommended-folder-structure/990/2 "2016-12-23T00:38:51Z")

</div>

> Is it because the node\_modules is in the top folder? What is the best practice?

It works ok the node\_modules is in the top folder. There may be other causes.

I think the folder structure of multiple services looks like

```auto
serverless-projects
  - project1
  -- handler.js
  -- serverless.yml
  - project2
  -- handler.js
  -- serverless.yml
  - package.json
  - node_modules

```

The following repository has examples of a serverless project. I think that it is good to try it also here.

> **[GitHub - serverless/examples: Serverless Examples – A collection of...](https://github.com/serverless/examples)**
>
> Serverless Examples – A collection of boilerplates and examples of serverless architectures built with the Serverless Framework on AWS Lambda, Microsoft Azure, Google Cloud Functions, and more. - G...

---

<div class="post-metadata">

**Author:** ![carmely](https://avatars.discourse-cdn.com/v4/letter/c/e99b99/32.png) [@carmely](https://forum.serverless.com/u/carmely)\
**Post date:** [December 23, 2016, 2:12am UTC](https://forum.serverless.com/t/what-is-the-recommended-folder-structure/990/3 "2016-12-23T02:12:31Z")

</div>

or is it better to put it into each individual services, as we need to optimize the zipped file size to be uploaded to lambda?

---

<div class="post-metadata">

**Author:** ![horike37](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/horike37/32/345_2.png) [@horike37](https://forum.serverless.com/u/horike37)\
**Post date:** [December 23, 2016, 2:26am UTC](https://forum.serverless.com/t/what-is-the-recommended-folder-structure/990/4 "2016-12-23T02:26:42Z")

</div>

> or is it better to put it into each individual services, as we need to optimize the zipped file size to be uploaded to lambda?

Yes, I think so.
