I have deployed the NestJS app to AWS Lambda, and there's an error message :
Cannot find module 'hbs'
PS :
Module hbs has been installed locally using npm install hbs --save
it's running well in my local
is there anyone who knows how to trace this issue in AWS Lambda? My feeling tells me that I have to trace this module in AWS Lambda, to make sure it's uploaded, but I don't know how to trace it.
You either have your lambda in and it's node_modules in s3 or you have your lambda deployed on a container using ECR , if it's the first case make sure you have the module in your node_module directory and if it's the second case make sure that you have your package in package.json and npm install in your Dockerfile.
Related
I'm trying to run a Node application on AWS Linux 2 on Elastic Beanstalk and need to install the dependencies using yarn. (My Node app causes errors if you try to use npm to install dependencies instead of yarn.)
I've already figured out how to set up a script in .platform/hooks/prebuild/ to get it to run yarn, but even though it's running the yarn installation, it still also tries to run npm install, which errors out, causing my deploy to fail.
So I need to figure out how to prevent the default npm install step from running.
(Does anyone know what file that command is run from in the AWS Linux 2 setup process? I was wondering if I could just add another script in .platform/hooks/prebuild/ that would modify that file to prevent the call to npm.)
yes, you can avoid npm install
When you deploy a node_modules directory to an Amazon Linux 2 Node.js platform version, Elastic Beanstalk assumes that you're providing your own dependency packages, and avoids installing dependencies specified in a package.json file.
source doc
I want to deploy my aws lambda by serverless, the repo is here: https://github.com/Jeff-Tian/serverless-space.
Basically it's a nest serverless app, and I configured my serverless.yml to use layer manager so I can put my node_modules into that layer.
I installed the production-only node_modules so the size is only 93M. But if I ran serverless deploy then the error occurs, claiming my unzipped size exceeds 250M.
Then I checked my node_moudles size again by du -h -d 0 node_modules, it shows it's 400+ M now.
So I guess the serverless deploy installed extra packages to my node_modules, and can be fixed by install serverless plugins globally. But unfortunately there is no this kind of option: https://github.com/serverless/serverless/issues/3319#issuecomment-303080193.
Can anyone shed some lights here?
Thanks in advance!
Currently can workaround it by
npm install -g serverless
npm install -g serverless-plugin-names
serverless deploy
I have an application I wrote on nodejs. It works fine on my local machine. Then I decided to test it on a live server. I moved the application to an AWS EC2 instance. When I run "npm install", ejs module always fail to install.
Here is the error
I could install it with this version of ejs
npm i ejs#2.7.1
i hope it works for you
I'm using Amazon's web-based code editor to create a simple proof-of-concept, using node.js and Lambda.
I would like to install an NPM package, but I haven't found any way to do this-- if I used the Cloud 9 development environment, I'm able to get a terminal window which allows me to run NPM, but Cloud 9 isn't available in NorCal, where I want to place my code.
Every search that I run instructs me to install node.js on my local machine, create the project, then zip the file and upload it to Lambda.
Is there any way to run NPM without installing node.js locally? Or should I just consider moving to an environment where I can use Cloud 9?
I am trying to write a function for Alexa skill for reminders. I already wrote the Lambda function for that including ical declaration but whenever I execute that code it shows 'ical' module is not defined. Please can you give any solution.
Follow this steps to use npm packages in your lambda function.
Create a new folder for your application in your local machine. Ex. my-app
Add all your Javascript files and package.json.
Include all you npm dependencies in package.json
Install all npm modules using npm install. All node modules will be installed and npm_modules folder will be created inside your project.
Zip your complete project folder (my-app.zip)
Upload your zip file in aws lambda console
Finally execute your test & run your lamdba function.