GithubHelp home page GithubHelp logo

require is not a function about faunadb-js HOT 7 CLOSED

fauna avatar fauna commented on June 3, 2024
require is not a function

from faunadb-js.

Comments (7)

iamtekeste avatar iamtekeste commented on June 3, 2024 1

For what it is worth I have found a workaround for it, turns out Netlify Dev/Netlify Lambda accepts a config param and you can pass it a custom webpack.config.js file.
More info here netlify/netlify-faunadb-example#8

from faunadb-js.

erickpintor avatar erickpintor commented on June 3, 2024

Hi @kevupton. Unfortunately, I'm not able to simulate this error. It seems to be a known issue with formidable, a sub-dependency of the JS driver. Would you mind trying their recommended workaround and reporting back, please?

from faunadb-js.

kevupton avatar kevupton commented on June 3, 2024

Hey @erickpintor somethign super weird is happening. I am going to list out all the details as I have no idea what is going on.

So I added the fix they recommended: new webpack.DefinePlugin({ "global.GENTLY": false }) and this worked when I was only using webpack. If I use webpack and serverless together it seems to break as above.

However webpack on its on requires me to remove the '' from the

  resolve: {
    extensions: ['.ts', '.js', '.tsx', '.jsx', '']
  },

otherwise it will error out, saying invalid configuration object webpack resolve extension empty string

However when I remove that and run webpack with serverless. I receive the following error. Entry module not found: Error: Cannot resolve 'file' or 'directory'

So I add the '' back into the extensions and then that fixes the above error message, however will then break on the original error messages.

So the conclusion is it seems to only break when I combine serverless and webpack. Which is unusal, as the webpack versions are the same, when I run it without serverless and with serverless.

My webpack configuration object is as follows:

module.exports = {
  entry: './handler.ts',
  target: 'node',
  module: {
    loaders: [
      { test: /\.ts(x?)$/, loader: 'ts-loader' },
      { test: /\.json$/, loader: 'json-loader' },
    ]
  },
  resolve: {
    extensions: ['.ts', '.js', '.tsx', '.jsx']
  },
  output: {
    libraryTarget: 'commonjs',
    path: path.join(__dirname, '.webpack'),
    filename: 'handler.js'
  },
  plugins: [
    new webpack.IgnorePlugin(/vertx/),
    new webpack.DefinePlugin({ "global.GENTLY": false })
  ]
};

If you can point me in a direction I would be very much appreciated. This has me stumped for a few days now.

from faunadb-js.

kevupton avatar kevupton commented on June 3, 2024

So I have solved the problem, and it seemed to be caused by an outdated version of the serverless-webpack plugin. RIP
Just had to update that plugin and then it worked

from faunadb-js.

erickpintor avatar erickpintor commented on June 3, 2024

I'm glad you've found the solution. Thanks for replying back to us.
I'm going to close this for now but, feel free to open new issues if need any help.

from faunadb-js.

iamtekeste avatar iamtekeste commented on June 3, 2024

I am facing this issue and since I am using Netlify Dev, I don't think there is a way I can modify my webpack.config.json.
Is there any other way I can get over this obstacle, I am really eager to use FaunaDB but I am unable to to do anything so far.

from faunadb-js.

danieltodonnell avatar danieltodonnell commented on June 3, 2024

@iamtekeste We will talk about this in our standup tomorrow and see what we can work out about it?

from faunadb-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.