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

gatsby-source-contentful not working #1588

Closed
YuyingWu opened this issue Jul 23, 2017 · 6 comments
Closed

gatsby-source-contentful not working #1588

YuyingWu opened this issue Jul 23, 2017 · 6 comments

Comments

@YuyingWu
Copy link

node: v6.10.2
npm: 3.10.10
gatsby: ^1.1.0
gatsby-source-contentful: 1.3.0

When I add gatsby-source-contentful to gatsby-config.js and I run gatsby develop, an error is thrown. Then I delete gatsby-source-contentful from gatsby-config.js, everything is all good again.

Please help me find out what's going on, thanks.

success open and validate gatsby-config.js — 0.008 s

One or more of your plugins have changed since the last time you ran Gatsby. As
a precaution, we're deleting your site's cache to ensure there's not any stale
data

success copy gatsby files — 0.045 s
⠄ source and transform nodesStarting to fetch data from Contentful
Fetching default locale
⠠ source and transform nodesdefault local is : zh-CN
⠠ source and transform nodescontentTypes fetched 3
Updated entries  6
Deleted entries  0
Updated assets  6
Deleted assets  0
Fetch Contentful data: 5283.946ms
⠐ source and transform nodes/Users/wyy/Documents/code/gatsby-blog/node_modules/_bluebird@3.5.0@bluebird/js/release/async.js:61
        fn = function () { throw arg; };
                           ^

TypeError: Path must be a string. Received undefined
    at assertPath (path.js:7:11)
    at Object.parse (path.js:1494:5)
    at Object.exports.onCreateNode (/Users/wyy/Documents/code/gatsby-blog/gatsby-node.js:10:33)
    at runAPI (/Users/wyy/Documents/code/gatsby-blog/node_modules/_gatsby@1.3.2@gatsby/dist/utils/api-runner-node.js:105:36)
    at /Users/wyy/Documents/code/gatsby-blog/node_modules/_gatsby@1.3.2@gatsby/dist/utils/api-runner-node.js:179:33
    at /Users/wyy/Documents/code/gatsby-blog/node_modules/_async@2.5.0@async/internal/map.js:27:9
    at replenish (/Users/wyy/Documents/code/gatsby-blog/node_modules/_async@2.5.0@async/internal/eachOfLimit.js:64:17)
    at iterateeCallback (/Users/wyy/Documents/code/gatsby-blog/node_modules/_async@2.5.0@async/internal/eachOfLimit.js:49:17)
    at /Users/wyy/Documents/code/gatsby-blog/node_modules/_async@2.5.0@async/internal/onlyOnce.js:12:16
    at /Users/wyy/Documents/code/gatsby-blog/node_modules/_async@2.5.0@async/internal/map.js:29:13
    at tryCatcher (/Users/wyy/Documents/code/gatsby-blog/node_modules/_bluebird@3.5.0@bluebird/js/release/util.js:16:23)
    at Promise.successAdapter (/Users/wyy/Documents/code/gatsby-blog/node_modules/_bluebird@3.5.0@bluebird/js/release/nodeify.js:23:30)
    at Promise._settlePromise (/Users/wyy/Documents/code/gatsby-blog/node_modules/_bluebird@3.5.0@bluebird/js/release/promise.js:566:21)
    at Promise._settlePromiseCtx (/Users/wyy/Documents/code/gatsby-blog/node_modules/_bluebird@3.5.0@bluebird/js/release/promise.js:606:10)
    at Async._drainQueue (/Users/wyy/Documents/code/gatsby-blog/node_modules/_bluebird@3.5.0@bluebird/js/release/async.js:138:12)
    at Async._drainQueues (/Users/wyy/Documents/code/gatsby-blog/node_modules/_bluebird@3.5.0@bluebird/js/release/async.js:143:10)

npm ERR! Darwin 16.6.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "serve"
npm ERR! node v6.10.2
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! gatsby-starter-advanced@1.0.0 serve: `gatsby develop`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the gatsby-starter-advanced@1.0.0 serve script 'gatsby develop'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the gatsby-starter-advanced package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     gatsby develop
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs gatsby-starter-advanced
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls gatsby-starter-advanced
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/wyy/Documents/code/gatsby-blog/npm-debug.log
@KyleAMathews
Copy link
Contributor

Could you try the contentful example site? https://github.com/gatsbyjs/gatsby/tree/master/examples/using-contentful

@cpinnix
Copy link
Contributor

cpinnix commented Aug 5, 2017

I got a similar error tonight. Went ahead and pulled down the example site.

git clone https://github.com/gatsbyjs/gatsby.git
cd gatsby/examples/using-contentful
yarn install
yarn build

And received this error.

success open and validate gatsby-config.js — 0.006 s
success copy gatsby files — 0.017 s
⠁ Starting to fetch data from Contentful
Fetching default locale
⠂ source and transform nodesdefault local is : en-US
⡀ source and transform nodescontentTypes fetched 3
Updated entries  9
Deleted entries  0
Updated assets  11
Deleted assets  0
Fetch Contentful data: 235.936ms
success source and transform nodes — 0.330 s
success building schema — 0.164 s
success createPages — 0.027 s
success createPagesStatefully — 0.022 s
success extract queries from components — 0.108 s
success run graphql queries — 0.209 s
success write out page data — 0.003 s
success update schema — 0.131 s

bootstrap finished, time since started: 1.978 s

Generating CSS
fs.js:1053
  return binding.unlink(pathModule._makeLong(path));
                 ^

Error: ENOENT: no such file or directory, unlink '/Users/xyz/git/gatsby/examples/using-contentful/public/bundle-for-css.js'
    at Object.fs.unlinkSync (fs.js:1053:18)
    at /Users/xyz/git/gatsby/examples/using-contentful/node_modules/gatsby/dist/utils/build-css.js:49:35
    at Compiler.<anonymous> (/Users/xyz/git/gatsby/examples/using-contentful/node_modules/webpack/lib/Compiler.js:194:14)
    at Compiler.emitRecords (/Users/xyz/git/gatsby/examples/using-contentful/node_modules/webpack/lib/Compiler.js:282:37)
    at Compiler.<anonymous> (/Users/xyz/git/gatsby/examples/using-contentful/node_modules/webpack/lib/Compiler.js:187:11)
    at /Users/xyz/git/gatsby/examples/using-contentful/node_modules/webpack/lib/Compiler.js:275:11
    at Compiler.applyPluginsAsync (/Users/xyz/git/gatsby/examples/using-contentful/node_modules/tapable/lib/Tapable.js:60:69)
    at Compiler.afterEmit (/Users/xyz/git/gatsby/examples/using-contentful/node_modules/webpack/lib/Compiler.js:272:8)
    at Compiler.<anonymous> (/Users/xyz/git/gatsby/examples/using-contentful/node_modules/webpack/lib/Compiler.js:267:14)
    at /Users/xyz/git/gatsby/examples/using-contentful/node_modules/async/lib/async.js:52:16
    at Object.async.forEachOf.async.eachOf (/Users/xyz/git/gatsby/examples/using-contentful/node_modules/async/lib/async.js:236:30)
    at Object.async.forEach.async.each (/Users/xyz/git/gatsby/examples/using-contentful/node_modules/async/lib/async.js:209:22)
    at Compiler.emitFiles (/Users/xyz/git/gatsby/examples/using-contentful/node_modules/webpack/lib/Compiler.js:235:20)
    at /Users/xyz/git/gatsby/examples/using-contentful/node_modules/mkdirp/index.js:48:26
    at FSReqWrap.oncomplete (fs.js:153:5)
error Command failed with exit code 1.

@3CordGuy
Copy link
Contributor

3CordGuy commented Sep 5, 2017

I'm also experiencing the same issue just adding the plugin for contentful as @YuyingWu. Really would like to get this data layer working.

Fetch Contentful data: 728.460ms
⢀ source and transform nodes/Users/xxxx/node_modules/bluebird/js/release/async.js:61
        fn = function () { throw arg; };
                           ^

TypeError: Path must be a string. Received undefined
    at assertPath (path.js:7:11)
    at Object.parse (path.js:1494:5) 
...

@KyleAMathews
Copy link
Contributor

Try using Yarn.

npm install -g yarn@latest
rm -r node_modules
yarn
gatsby develop

I just reinstalled the contentful example site and it worked as expected.

@sandy1987
Copy link

success delete html files from previous builds — 0.018 s
success open and validate gatsby-config.js — 0.005 s
info One or more of your plugins have changed since the last time you ran Gatsby. As
a precaution, we're deleting your site's cache to ensure there's not any stale
data
success copy gatsby files — 0.018 s
⠁ Starting to fetch data from Contentful
Fetching default locale
⠈ source and transform nodesdefault local is : en-GB
⠂ source and transform nodescontentTypes fetched 1
Updated entries 2
Deleted entries 0
Updated assets 1
Deleted assets 0
Fetch Contentful data: 3433.285ms
success source and transform nodes — 3.467 s
success building schema — 0.129 s
success createLayouts — 0.039 s
⠁ createPages

problem occur while createPages. It doesn't give any type of error. but still stay on there. . .. Any idea? Please suggest

@KyleAMathews
Copy link
Contributor

The error is in your code. Add some console.log in your gatsby-node's createPages function

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

No branches or pull requests

5 participants