I need some help adding faunaDB to my project


I have a very simple project only using functions. But when I add this simple line to my code

const faunadb = require('faunadb')

I get the following error when I call my function

   [ ' may need an appropriate loader to handle this file type.',
     '   body: body,',
     '   headers: util.removeNullAndUndefinedValues({',
     '     ...this._headers,',
     '     Authorization: secret && secretHeader(secret),',
     '     \'X-FaunaDB-API-Version\': APIVersion,',

level: ‘error’,
[Symbol(level)]: ‘error’,

I tried to copy the examples to my folder and they all give me the same error just by calling them.

Any idea? this is probably a very simple problem But I can’t find any info about it.


Hi @Israel_Lazo, welcome to the Community!

Could you share the complete function code and also let us know how you are deploying your functions? These two things will help us check if it’s syntax issue or an issue with how you are deploying your function.

Hi @Dennis, thanks for replying!

Even with a simple hello world I get that error, let’s say

exports.handler = function(event, context, callback) {
callback(null, {
statusCode: 200,
body: “Hello, World”

const faunadb = require(‘faunadb’)
exports.handler = function(event, context, callback) {
callback(null, {
statusCode: 200,
body: “Hello, World”

Maybe it’s some configuration i’m missing? I can give you access to my repository.

Error: Module parse failed: Unexpected token (237:6)
You may need an appropriate loader to handle this file type.

I’m deploying from butbucket if that was the question about ‘how i’m deploying’

I think I meant how you are bundling your function. Are you using netlify-lambda or are you using the built-in zip-it-and-ship-it bundling in our buildbot? You can see the 3 ways to deploy/bundle a lambda function here: https://github.com/netlify/function-deploy-test/.

These are my build/run scripts, i’m using the sample netlify project

"scripts": {
"docs": "node generate-readme.js",
"test": "echo \"Error: no test specified\" && exit 1",
"start": "concurrently 'yarn start:client' 'yarn start:server'",
"start:client": "webpack-dev-server --mode development --hot --config webpack.client.js",
"start:server": "netlify-lambda serve src/lambda -c webpack.server.js",
"build": "yarn build:client && yarn build:server",
"build:client": "webpack --mode production --config webpack.client.js",
"build:server": "netlify-lambda build src/lambda",
"dev": "netlify dev"


Hey @Israel_Lazo,
I think this is the demo you’re working from? https://github.com/netlify/functions Unfortunately, it’s very possible that that example no longer works :frowning_face: It looks like it hasn’t been touched in over a year.

This one looks a bit more recent if you’d like to give it a try:

I just walked through it and found that there were a bunch of deprecated packages, but the site does build and launch:

I’d skip the local testing and “Deploy to Netlify” button- instead, just fork and clone the repo, then work through the README to set up a free FaunaDB database, etc. You’ll need to set an environment variable in the Netlify UI called FAUNADB_SERVER_SECRET with your database server secret.

Thanks for bearing with us on this and please let us know if we can help further!

Thank you.

I’ve already started from that repo instead.

1 Like