Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

__webpack_require__(...) is not a function #186

Closed
PatrikElfstrom opened this issue Oct 20, 2019 · 11 comments · Fixed by #187
Closed

__webpack_require__(...) is not a function #186

PatrikElfstrom opened this issue Oct 20, 2019 · 11 comments · Fixed by #187

Comments

@PatrikElfstrom
Copy link

I'm running FaunaDB in a Netlify Function built with Webpack and I get this error:
Error during invocation: TypeError: __webpack_require__(...) is not a function

This is because of a bug in isomorphic-unfetch: developit/unfetch#122

PatrikElfstrom added a commit to PatrikElfstrom/schnitzellunch that referenced this issue Oct 20, 2019
@BrunoQuaresma
Copy link
Contributor

@PatrikElfstrom what driver version are you using?

@PatrikElfstrom
Copy link
Author

PatrikElfstrom commented Oct 20, 2019

I am using v2.9.2

@danieltodonnell
Copy link
Contributor

Thanks for reporting this. we will look into it on Monday.

@BrunoQuaresma
Copy link
Contributor

BrunoQuaresma commented Oct 21, 2019

@PatrikElfstrom I'm using netlify cli and faunadb v.2.9.2 and the following code is working good.

const { Client, query: q } = require('faunadb')
const db = new Client({ secret: '...' })

exports.handler = async event => {
  if (event.httpMethod !== 'POST') {
    return { statusCode: 405, body: 'Method Not Allowed' }
  }

  const data = JSON.parse(event.body)

  try {
    const { ... } = await db.query(
      q.Let(...)
    )

    return {
      statusCode: 200,
      body: JSON.stringify({ ... }),
    }
  } catch (error) {
    return {
      statusCode: 500,
      body: JSON.stringify({ ... })
    }
  }
}

Can you share with us more details about the tools you are using?

@PatrikElfstrom
Copy link
Author

PatrikElfstrom commented Oct 21, 2019 via email

@PatrikElfstrom
Copy link
Author

@BrunoQuaresma Similar error with your code just n(...) is not a function which I guess is the same function.

This is the repo: https://github.com/PatrikElfstrom/schnitzellunch
It's a pretty bog standard create-react-app.
If your going to run that you need to change the urls in src/lambda/restaurants-recrawl.js to http://localhost:8888
And then open http://localhost:8888/.netlify/functions/restaurants-recrawl and you should get the error in the console.

I've tried with node v10.16.3 and v12.13.0 but the same error.
And the row number points me to line 3 here which is the loading of node-fetch

module.exports = global.fetch = global.fetch || (
	typeof process=='undefined' ? (__webpack_require__(/*! unfetch */ "../../node_modules/unfetch/dist/unfetch.mjs").default || __webpack_require__(/*! unfetch */ "../../node_modules/unfetch/dist/unfetch.mjs")) : (function(url, opts) {
		return __webpack_require__(/*! node-fetch */ "../../node_modules/node-fetch/lib/index.mjs")(url.replace(/^\/\//g,'https://'), opts);
	})
);

(And placing .default just after __webpack_require__(...) solves the issue)

@khrome83
Copy link

I am having this issue also. I spent all day trying to solve it.
@danieltodonnell - are you cutting a release.

@danieltodonnell
Copy link
Contributor

we are cutting 2.9.3 in the next hour or two. For now use the 2.9.3-pre1 prerelease. it is identical to the actual release

@khrome83
Copy link

@danieltodonnell - I really appreciate the responsiveness. Thank you!

@danieltodonnell
Copy link
Contributor

Hello everyone, I appreciate your patience with this matter. JS Drivers v2.9.3 have been released
https://www.npmjs.com/package/faunadb/v/2.9.3

This should hopefully address your issues, but if not, please open an issue and we will address it asap (usually the same or next day).

Thank you!

@khrome83
Copy link

@danieltodonnell - worked like a charm. I did my first transaction too my FaunaDB.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants