datocms / gatsby-source-datocms

Official GatsbyJS source plugin to pull content from DatoCMS
MIT License
140 stars 51 forks source link

[v2] TypeError: EntitiesRepo is not a constructor #26

Closed marcammann closed 6 years ago

marcammann commented 6 years ago

I tried setting up a vanilla Gatsby v2 instance this morning and I'm getting stuck right after the configuration.

Using version gatsby-source-datocms @ 2.0.0-alpha.2 and datocms-client @ 0.5.7 (tried 0.6.0 as well)

This is the error:

success open and validate gatsby-config — 0.012 s
success load plugins — 0.255 s
success onPreInit — 0.652 s
success delete html and css files from previous builds — 0.009 s
success initialize cache — 0.017 s
success copy gatsby files — 0.044 s
success onPreBootstrap — 0.001 s
error Plugin gatsby-source-datocms returned an error

  TypeError: EntitiesRepo is not a constructor

  - fetch.js:14
    [Web]/[gatsby-source-datocms]/fetch.js:14:12

  - next_tick.js:61 process._tickCallback
    internal/process/next_tick.js:61:11

error UNHANDLED REJECTION

  TypeError: Cannot read property 'filter' of undefined

  - api-runner-node.js:257 Promise.mapSeries.catch.then.results
    [Web]/[gatsby]/dist/utils/api-runner-node.js:257:42

  - util.js:16 tryCatcher
    [Web]/[bluebird]/js/release/util.js:16:23

  - promise.js:512 Promise._settlePromiseFromHandler
    [Web]/[bluebird]/js/release/promise.js:512:31

  - promise.js:569 Promise._settlePromise
    [Web]/[bluebird]/js/release/promise.js:569:18

  - promise.js:614 Promise._settlePromise0
    [Web]/[bluebird]/js/release/promise.js:614:10

  - promise.js:693 Promise._settlePromises
    [Web]/[bluebird]/js/release/promise.js:693:18

  - async.js:133 Async._drainQueue
    [Web]/[bluebird]/js/release/async.js:133:16

  - async.js:143 Async._drainQueues
    [Web]/[bluebird]/js/release/async.js:143:10

  - async.js:17 Immediate.Async.drainQueues [as _onImmediate]
    [Web]/[bluebird]/js/release/async.js:17:14

What I tracked it down to is that the default exports from datocms-client need an extra .default argument as default isn't not automatically resolved. I found some notes that Babel now doesn't automatically access the default property anymore. Even trying to set output.libraryExport in the Webpack config override didn't do the trick.

shansmith01 commented 6 years ago

I am getting the same issue as well.

Details below if it's useful

  TypeError: EntitiesRepo is not a constructor

  - fetch.js:14
    [mad]/[gatsby-source-datocms]/fetch.js:14:12

  - next_tick.js:150 process._tickCallback
    internal/process/next_tick.js:150:11

error UNHANDLED REJECTION

  TypeError: Cannot read property 'filter' of undefined

  - api-runner-node.js:257 Promise.mapSeries.catch.then.results
    [mad]/[gatsby]/dist/utils/api-runner-node.js:257:42

  - util.js:16 tryCatcher
    [mad]/[bluebird]/js/release/util.js:16:23

  - promise.js:512 Promise._settlePromiseFromHandler
    [mad]/[bluebird]/js/release/promise.js:512:31

  - promise.js:569 Promise._settlePromise
    [mad]/[bluebird]/js/release/promise.js:569:18

  - promise.js:614 Promise._settlePromise0
    [mad]/[bluebird]/js/release/promise.js:614:10

  - promise.js:693 Promise._settlePromises
    [mad]/[bluebird]/js/release/promise.js:693:18

  - async.js:133 Async._drainQueue
    [mad]/[bluebird]/js/release/async.js:133:16

  - async.js:143 Async._drainQueues
    [mad]/[bluebird]/js/release/async.js:143:10

  - async.js:17 Immediate.Async.drainQueues [as _onImmediate]
    [mad]/[bluebird]/js/release/async.js:17:14

Here is my dependencies from package.json

"dependencies": {
    "babel-plugin-styled-components": "^1.5.1",
    "gatsby": "next",
    "gatsby-image": "next",
    "gatsby-plugin-react-helmet": "next",
    "gatsby-plugin-sharp": "^2.0.0-beta.7",
    "gatsby-plugin-styled-components": "^3.0.0-beta.3",
    "gatsby-source-datocms": "^2.0.0-alpha.2",
    "gatsby-transformer-sharp": "^2.1.1-beta.6",
    "react": "^16.4.1",
    "react-dom": "^16.4.1",
    "react-helmet": "^5.2.0",
    "react-reveal": "^1.2.2",
    "react-tooltip": "^3.6.1",
    "styled-components": "^3.3.3",
    "typeface-lato": "0.0.54"
  },

I have also tried deleting my lock file, removing npm, reinstalling. No luck.

jarred commented 6 years ago

I too am getting this error with an otherwise vanilla gatsby starter. Has something changed in the plugin recently? Or is this an issue with the Dato CMS API?

  "dependencies": {
    "dotenv": "^6.0.0",
    "gatsby": "^1.9.247",
    "gatsby-link": "^1.6.40",
    "gatsby-plugin-react-helmet": "^2.0.10",
    "gatsby-source-datocms": "^1.1.11",
    "react-helmet": "^5.2.0"
  },

...

module.exports = {
  siteMetadata: {
    title: 'Gatsby Default Starter',
  },
  plugins: [
    'gatsby-plugin-react-helmet',
    {
      resolve: `gatsby-source-datocms`,
      options: {
        apiToken: process.env.DATO_API_TOKEN,
        preview: false,
        disableLiveReload: false,
      },
    },
  ],
}
oscarehrling commented 6 years ago

Gett the same error here. Package.json and gatsby config:

"dependencies": {
    "autoprefixer": "^9.0.1",
    "final-form": "^4.8.3",
    "gatsby": "^1.9.277",
    "gatsby-link": "^1.6.45",
    "gatsby-plugin-react-helmet": "^2.0.11",
    "gatsby-plugin-react-next": "^1.0.11",
    "gatsby-source-datocms": "^1.1.11",
    "moment": "^2.22.2",
    "prop-types": "^15.6.2",
    "pure-react-carousel": "^1.13.2",
    "react-datepicker": "^1.5.0",
    "react-final-form": "^3.6.4",
    "react-helmet": "^5.2.0",
    "react-parallax": "^1.8.0"
  },

...

module.exports = {
  siteMetadata: {
    title: 'Site Title',
  },
  plugins: [
    `gatsby-plugin-react-next`,
    `gatsby-plugin-react-helmet`,
    {
      resolve: `gatsby-source-datocms`,
      options: {
        apiToken: process.env.DATO_CMS_TOKEN,
        previewMode: false,
        apiUrl: `https://site-api.datocms.com`,
      },
    }
  ],
}

Error message

  TypeError: EntitiesRepo is not a constructor

  - fetch.js:14
    [gatsby-testing]/[gatsby-source-datocms]/fetch.js:14:12

  - next_tick.js:131 _combinedTickCallback
    internal/process/next_tick.js:131:7

  - next_tick.js:180 process._tickCallback
    internal/process/next_tick.js:180:9
stefanoverna commented 6 years ago

We should have fixed the issue with v2.0.0-alpha.5