Error with netlify-lambda when upgrading it from 1.6.3 to 2.0.x but only when running within a Netlify deploy

Site name:

Sourced from: GitHub - vectronic/website: Vectronic website

I have an issue introduced by upgrading the package.json dependency of “netlify-lambda” with a major version change e.g. “^1.6.3” to "^2.0.3.

I use this as part of my site build as follows:

npx netlify-lambda build src/functions

When I do this locally it works fine. However when this runs as part of Netlify deploy I get the following in the deploy logs:

11:14:07 AM: Unexpected token {
11:14:07 AM: Function Dir: /opt/build/repo/build/functions
11:14:07 AM: Skipping functions preparation step: /opt/build/repo/build/functions not found

I cannot work out where this unexpected token { is coming from! Because it only fails on the Netlify deploy I am unable to debug fully what is happening. I have confirmed similar version of Node running locally and on Netlify (8.17.0) and locally it works with Node 12.x and 14.x.

I am not sure what else could be different which is not configured in netlify.toml etc.

At the very least is there any way to increase verbosity of the deploy logs? (Maybe there is, but I haven’t seen an option).

I can stay on netlify-lambda 1.6.3 for now and everything is fine, but at some point I will need to update to the 2.x release.

I haven’t posted this on the netlify-lambda GitHub project as it seems to work absolutely fine for 2.0.x when running locally. So I am suspicious of some difference between local and Netlify deploy environment, but have no idea how to determine or debug the difference.

Thanks in advance!

hey nick,

can you try a fresh, bare clone of your project and then running npm install and trying again to build your project locally? i am wondering if it works locally because it is somehow relying on cached dependencies.

if that does not help, please do let us know and we can take another look?

Hi there,

Very good idea! I wish I had thought of that…

So indeed, a fresh checkout and npm install reproduced the problem locally.

I did discover however that it broke when using Node 8 and worked with a later version (12 in my case)… so no need to change any source, just use a newer node version.

So I have set an environment variable in my deploy settings NODE_VERSION=12 and it’s all good now.


Your help is appreciated.