After deploying my Node.js/Express.js application to AWS Lambda, I encountered a bcrypt error

I'm currently facing an issue with getting my express.js app to run on AWS Lambda. Despite successfully deploying it using the serverless framework, I encounter a 500 internal error when testing requests. The log displays the following error message:

/var/task/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node: invalid ELF header
.

I attempted replacing bcrypt with bcryptjs, but the problem persists.

In my serverless.yml, I added the line below to prompt lambda to self-install bcrypt, yet it hasn't resolved the issue:

package:
  exclude:
    - node_modules/**

Any advice or suggestions?

Answer №1

First of all, make sure to include the necessary node modules in your project. AWS will not install any additional packages into the lambda node environment other than the aws-sdk.

Additionally, the error you are experiencing is likely due to developing on a Mac OS machine, causing the bcrypt binary from your machine to be included in the lambda upload.

Be sure to thoroughly remove bcrypt from your project dependencies when switching to bcryptjs.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

"Optimize Your Data with PrimeNG's Table Filtering Feature

I'm currently working on implementing a filter table using PrimeNG, but I'm facing an issue with the JSON structure I receive, which has multiple nested levels. Here's an example: { "id": "123", "category": "nice", "place": { "ran ...

Eliminate embedded document elements using $pull operation

Trying to implement a functionality in ExpressJS and Mongoose that involves removing items from subdocuments. Currently, only the first item is getting removed instead of all sub items. The goal is to delete "subitem 2" from the messages Array. Here is th ...

Setting custom parameters ($npm_config_) for npm scripts on Windows allows for more flexibility and customization in

I'm struggling with passing custom parameters from the command line to npm scripts in my package.json file. Despite researching on various platforms, including Stack Overflow, I haven't found a solution that works for me. Here's what I' ...

Please confirm and verify my comprehension of Express Routes

Before delving into the question at hand, I just wanted to confirm something. When I instantiate Express with const app = express(), is app an instance of the entire Express module? I ask because when I call app.route, is route an Express method or a NodeJ ...

Issue encountered while generating a fresh migration in TypeORM with NestJs utilizing Typescript

I am currently working on a Node application using TypeScript and I am attempting to create a new migration following the instructions provided by TypeORM. Initially, I installed the CLI, configured my connection options as outlined here. However, when I ...

Initiate the script once ng serve is running

Recently, I created a script to capture screenshots of my Angular application. However, I encountered an issue where the script only functions correctly if I manually start 'ng serve' before running the script. My concern is, is there a way to in ...

Using the MERN stack in conjunction with Socket for MongoDB provides the ability to display real-time data on the frontend directly

As I work on setting up a website using the MERN stack, my backend will continuously fetch data from APIs and sockets to save it in a MongoDB database. For the frontend React, I aim to display and update this data in real-time using Socket. I have concern ...

Having issues displaying the & symbol in HTML from backend data

I recently worked on a project using express handlebars, where I was fetching data from the YouTube API. However, the titles of the data contained special characters such as '# (the ' symbol) and & (the & symbol). When attempting to render the ...

Leveraging Node.js to copy files, checking for missing files through the utilization of fs.readdir, and

During my attempt to copy a large number of files within a folder using "ncp", I've encountered an issue where not all the files are successfully copied. After checking, it seems that some files are consistently missing. I resorted to using fs.readdi ...

How to handle FilePond uploads that need to be reverted when the DELETE request lacks a unique ID?

As a new user, I've been struggling with this issue for quite some time The problem I'm facing is that when I click the close button to undo the upload of a file, it triggers a DELETE request to the backend (using Express). However, the req.body ...

The Debian operating system has Nodejs installed, however npm is missing from the installation

While trying to install Nodejs v11.x on Debian by following the steps provided at https://github.com/nodesource/distributions, I encountered an issue. Even after successfully installing Nodejs, the command nodejs -v returns v4.8.2, indicating that npm has ...

Having trouble executing/locating JSHint

Just starting out with Grunt and struggling to set up a configuration file. I'm encountering some issues while trying to run JSHint as it can't seem to locate the file. Here is how my directory structure looks: ./htdocs/[js, css, sass, images, ...

Tips for accessing the result of a Node.js mysql query connection

New to Node.js and trying to retrieve data from a database using a select query. Below is my code: var address = socket.request.client._peername.address; var ip_addrss = address.split("::ffff:"); let mine = ip_addrss[1]; var location = iploc ...

There was an issue locating a declaration file for the module 'clarifai'

https://i.stack.imgur.com/PgfqO.jpg I recently encountered a problem after installing the Clarifai API for a face recognition project. Despite my efforts, I have been unable to find a solution. When I hover over "import clarifai," I receive the message: ...

The result of Document.getElementById can show as "undefined" despite the presence of the element

Currently, I am tackling a project that involves extracting information from a website. I have opted to use the 'puppeteer' library in Node.Js for this task. However, I am encountering an issue where Document.getElementById is returning "undefine ...

Having trouble with firebase admin code completions not functioning properly in vscode?

I've attempted to install the Typescript integration for Firebase using: npm install --save-dev @types/firebase Unfortunately, I have not had any success. The "firebase-admin" and "firebase-functions" packages do not provide code completion or intel ...

Oops! Looks like there's an issue with the rendering function or template in this component - it

After following the instructions in the tutorial at , I attempted to implement the example but encountered an issue that seems to be missing from the guide. const Vue = require('vue'); const server = require('express')(); const vssr = ...

Step-by-step guide on invoking a recursive function asynchronously in JavaScript

As I delved into the realm of creating a unique Omegle clone using Node.js and Socket.io for educational purposes, I encountered a challenge that has left me scratching my head. The socket ID of clients along with their interests are stored in an array of ...

The Typescript intellisense feature in VS Code seems to be malfunctioning

While setting up typings for my Node server, the intellisense suddenly stopped working. I checked my tsconfig.json file: { "version": "0.1.0", "command": "tsc", "isShellCommand": true, "args": ["-p", "."], "showOutput": "silent", " ...

Serve as a proxy for several hosts with identical URL structures

I've been utilizing the http-proxy-middleware to handle my API calls. Is there a way to proxy multiple target hosts? I've searched for solutions in the issues but still haven't found a clear answer. https://github.com/chimurai/http-proxy-m ...