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 });
};