Netlify function graphql typescript build errors

started with basic function typescript sample. Then when I add import for "apollo-server-lambda’ I get warnings when run build.

*WARNING in ../node_modules/subscriptions-transport-ws/node_modules/ws/lib/buffer-util.js*
*Module not found: Error: Can't resolve 'bufferutil'*
*WARNING in ../node_modules/subscriptions-transport-ws/node_modules/ws/lib/validation.js*
*Module not found: Error: Can't resolve 'utf-8-validate*

  "scripts": {
    "build": "netlify-lambda build src",
    "ts-check": "tsc --noEmit --lib ES2015 ./src/*.ts"

  "presets": [
        "targets": {
          "node": true

what does the dependencies section for your package.json look like?

Something I’d like to add is that, you’ve chosen just a src folder for the lambda build?
netlify-lambda is to build your functions, see here: you’ve got this as your only build command so it feels like you’re attempting to use it to build your site?

I had the same issue and fixed it by adding this to webpack:

const nodeExternals = require('webpack-node-externals');
Then add externals: nodeExternals(), to the webpack config.

1 Like