0

I'm trying to build a backend for dialogflow using netlify lambda function, as the website otherwise is supposed to be static-generated nuxt.js based landing page hosted there. Creating a simple resolution function works perfectly, reading and parsing credentials for authentication on Google goes without a problem, but the problem comes when trying to require dialogflow library. In the browser I get error Function invocation failed: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type number.

While running netlify-lambda serve I get a warning:

WARNING in /mnt/c/Projects/deploy-landing/node_modules/google-gax/node_modules/semver/index.js 3:51-64 Critical dependency: the request of a dependency is an expression.

As far as I understand, netlify-lambda is trying to use webpack on dialogflow module which in turn has some dependencies that requires node style dynamic module name resolutions. Is there any way to get around this issue?

Michał Sadowski
  • 1,946
  • 1
  • 11
  • 24

1 Answers1

0

I created a file webpack.functions.js:

module.exports = {
  externals: { dialogflow: 'dialogflow' }
};

Then in package.json I modified the scripts that I run to start lambda functions to use this config file:

{

  "scripts": {
    "lambda-build": "netlify-lambda build --config ./webpack.functions.js \"./netlify/dev\""
    ...
  }
  ...
}

As far as I understand netlify now doesn't bundle dialogflow and instead it is used as a node module. One way or another - it's working.

Michał Sadowski
  • 1,946
  • 1
  • 11
  • 24