gatsbyjs / gatsby

The best React-based framework with performance, scalability and security built in.
https://www.gatsbyjs.com
MIT License
55.28k stars 10.31k forks source link

TypeError: node.frontmatter.tags.map is not a function during gatsby develop #9339

Closed twhite96 closed 6 years ago

twhite96 commented 6 years ago

Description

Getting: TypeError: node.frontmatter.tags.m ap is not a function when running gatsby develop.

Steps to reproduce

Clear steps describing how to reproduce the issue. Please please please link to a demo project if possible, this makes your issue much easier to diagnose (seriously).

Expected result

What should happen? I expected to be able to see my site live in the dev environment but could not.

Actual result

Instead I get the TypeError: node.frontmatter.tags.m ap is not a function and the process shuts down. I am using Lumen starter. You can find my repo here.

This could really be an issue with my markdown files and the remark transform plugin but I am not sure.

EDIT: More info.

in TWBlog-newish git:(master ﯙ ?) is 📦 v2.0.2 node:( v10.12.0) took 4s
  gatsby develop
success delete html and css files from previous builds — 0.041 s
success open and validate gatsby-config — 0.004 s
success copy gatsby files — 0.054 s
success onPreBootstrap — 0.462 s
error UNHANDLED EXCEPTION

  TypeError: node.frontmatter.tags.m  ap is not a function

  - gatsby-node.js:117 Object.export    s.onCreateNode
    /Users/tiffanywhite/Desktop/Git_    Repositories/TWBlog-newish/gatsb    y-node.js:117:46

  - api-runner-node.js:110 runAPI
    [TWBlog-newish]/[gatsby]/dist/ut    ils/api-runner-node.js:110:36

  - api-runner-node.js:187
    [TWBlog-newish]/[gatsby]/dist/ut    ils/api-runner-node.js:187:33

  - map.js:27
    [TWBlog-newish]/[async]/internal    /map.js:27:9

  - eachOfLimit.js:66 replenish
    [TWBlog-newish]/[async]/internal    /eachOfLimit.js:66:17

  - eachOfLimit.js:50 iterateeCallba    ck
    [TWBlog-newish]/[async]/internal    /eachOfLimit.js:50:17

  - onlyOnce.js:12
    [TWBlog-newish]/[async]/internal    /onlyOnce.js:12:16

  - map.js:29
    [TWBlog-newish]/[async]/internal    /map.js:29:13

  - util.js:16 tryCatcher
    [TWBlog-newish]/[bluebird]/js/re    lease/util.js:16:23

  - nodeify.js:23 Promise.successAda    pter
    [TWBlog-newish]/[bluebird]/js/re    lease/nodeify.js:23:30

  - promise.js:566 Promise._settlePr    omise
    [TWBlog-newish]/[bluebird]/js/re    lease/promise.js:566:21

  - promise.js:606 Promise._settlePr    omiseCtx
    [TWBlog-newish]/[bluebird]/js/re    lease/promise.js:606:10

  - async.js:142 _drainQueueStep
    [TWBlog-newish]/[bluebird]/js/re    lease/async.js:142:12

  - async.js:131 _drainQueue
    [TWBlog-newish]/[bluebird]/js/re    lease/async.js:131:9

  - async.js:147 Async._drainQueues
    [TWBlog-newish]/[bluebird]/js/re    lease/async.js:147:5

  - async.js:17 Immediate.Async.drai    nQueues
    [TWBlog-newish]/[bluebird]/js/re    lease/async.js:17:14

Environment

System: OS: macOS 10.14.1 CPU: x64 Intel(R) Core(TM) i5-6500 CPU @ 3.20GHz Shell: 5.3 - /bin/zsh Binaries: Node: 10.12.0 - ~/.nvm/versions/node/v10.12.0/bin/node Yarn: 1.10.1 - /usr/local/bin/yarn npm: 6.4.1 - ~/.nvm/versions/node/v10.12.0/bin/npm Browsers: Firefox: 62.0.3 Safari: 12.0.1 npmPackages: gatsby: ^1.9.164 => 1.9.279 gatsby-link: ^1.6.34 => 1.6.46 gatsby-plugin-catch-links: ^1.0.14 => 1.0.26 gatsby-plugin-feed: ^1.3.15 => 1.3.25 gatsby-plugin-google-analytics: ^1.0.15 => 1.0.31 gatsby-plugin-google-fonts: latest => 0.0.4 gatsby-plugin-offline: ^1.0.12 => 1.0.18 gatsby-plugin-postcss-sass: ^1.0.15 => 1.0.22 gatsby-plugin-react-helmet: ^2.0.3 => 2.0.11 gatsby-plugin-sharp: ^1.6.25 => 1.6.48 gatsby-plugin-sitemap: ^1.2.10 => 1.2.25 gatsby-remark-copy-linked-files: ^1.5.25 => 1.5.37 gatsby-remark-images: ^1.5.37 => 1.5.67 gatsby-remark-prismjs: ^1.2.12 => 1.2.24 gatsby-remark-responsive-iframe: ^1.4.16 => 1.4.20 gatsby-remark-smartypants: ^1.4.10 => 1.4.12 gatsby-source-filesystem: ^1.5.11 => 1.5.39 gatsby-transformer-remark: ^1.7.28 => 1.7.44 gatsby-transformer-sharp: ^1.6.16 => 1.6.27

kakadiadarpan commented 6 years ago

@twhite96 I'm able to run gatsby develop successfully for the repo link you shared.

screenshot 2018-10-24 at 2 56 18 pm

Steps followed:

  1. Clone the repo.
  2. Run yarn
  3. Run yarn develop

Environment info

  System:
    OS: macOS 10.14
    CPU: x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
    Shell: 5.3 - /bin/zsh
  Binaries:
    Node: 10.9.0 - /usr/local/bin/node
    Yarn: 1.9.4 - /usr/local/bin/yarn
    npm: 6.4.1 - /usr/local/bin/npm
  Browsers:
    Chrome: 70.0.3538.67
    Firefox: 62.0.3
    Safari: 12.0
  npmPackages:
    gatsby: ^1.9.164 => 1.9.279 
    gatsby-link: ^1.6.34 => 1.6.46 
    gatsby-plugin-catch-links: ^1.0.14 => 1.0.26 
    gatsby-plugin-feed: ^1.3.15 => 1.3.25 
    gatsby-plugin-google-analytics: ^1.0.15 => 1.0.31 
    gatsby-plugin-google-fonts: latest => 0.0.4 
    gatsby-plugin-offline: ^1.0.12 => 1.0.18 
    gatsby-plugin-postcss-sass: ^1.0.15 => 1.0.22 
    gatsby-plugin-react-helmet: ^2.0.3 => 2.0.11 
    gatsby-plugin-sharp: ^1.6.25 => 1.6.48 
    gatsby-plugin-sitemap: ^1.2.10 => 1.2.25 
    gatsby-remark-copy-linked-files: ^1.5.25 => 1.5.37 
    gatsby-remark-images: ^1.5.37 => 1.5.67 
    gatsby-remark-prismjs: ^1.2.12 => 1.2.24 
    gatsby-remark-responsive-iframe: ^1.4.16 => 1.4.20 
    gatsby-remark-smartypants: ^1.4.10 => 1.4.12 
    gatsby-source-filesystem: ^1.5.11 => 1.5.39 
    gatsby-transformer-remark: ^1.7.28 => 1.7.44 
    gatsby-transformer-sharp: ^1.6.16 => 1.6.27 
  npmGlobalPackages:
    gatsby-cli: 2.4.1
twhite96 commented 6 years ago

Okay. Will try again.

twhite96 commented 6 years ago

Actually this is the wrong repo. I didn't add my posts to this repo. Will share that one.

twhite96 commented 6 years ago

@kakadiadarpan this is the one with the posts here.

kakadiadarpan commented 6 years ago

@twhite96 The issue seems to be coming because of the following line in gatsby-node.js:

// gatsby-node.js Line 116
const tagSlugs = node.frontmatter.tags.map(tag => `/tags/${_.kebabCase(tag)}/`);

The value that you get for node.frontmatter.tags is not always an array and that's why you are getting this error.

twhite96 commented 6 years ago

@kakadiadarpan hmmmmm. I'm not sure what you mean. New to Gatsby and I'm using a starter. So is it because the tags in my front matter sometimes use an array and sometimes not?

twhite96 commented 6 years ago

Ohhhhhhhhh okay I see now. I'll change those posts then. Thanks.

kakadiadarpan commented 6 years ago

@twhite96 We'll be closing this issue. Feel free to open a new one if you need more help 👍