hasura / gatsby-gitbook-starter

Generate GitBook style modern docs/tutorial websites using Gatsby + MDX
https://hasura.io/learn/graphql/react/introduction/
MIT License
983 stars 378 forks source link

Fixed Issue with npm start #101

Closed hiteshsahu closed 3 years ago

hiteshsahu commented 3 years ago

Error Logs:


success run queries - 0.184s - 8/8 43.47/s

 ERROR #98123  WEBPACK

Generating SSR bundle failed

C:\Users\HiteshKumarSahu\Documents\TestSpace\Gatsby\gatsby-gitbook-starter\src\components\mdxComponents\codeBlock.js: Support for the experimental syntax 'nullishCoalescingOperator' isn't currently enabled (33:95):

  31 |   } else {
  32 |     return (
> 33 |       <Highlight {...defaultProps} code={exampleCode} language={props.className.split("-")[1] ?? "javascript"} theme={prismTheme}>
     |                                                                                               ^
  34 |         {({ className, style, tokens, getLineProps, getTokenProps }) => (
  35 |           <pre className={className + ' pre'} style={style} p={3}>
  36 |             {cleanTokens(tokens).map((line, i) => {

Add @babel/plugin-proposal-nullish-coalescing-operator (https://git.io/vb4Se) to the 'plugins' section of your Babel config to enable transformation.

File: src\components\mdxComponents\codeBlock.js:33:94

———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
5 pages                                                                                    In Progress                                                                                   gatsby-gitbook-boilerplate
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! gatsby-gitbook-boilerplate@0.0.1 start: `gatsby develop`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the gatsby-gitbook-boilerplate@0.0.1 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
gempain commented 3 years ago

@hiteshsahu I found another way to work around this problem, as mentioned in #102, you can add the @babel/plugin-proposal-nullish-coalescing-operator to the dependencies in package.json and update gatsby-node.js with

exports.onCreateBabelConfig = ({ actions }) => {
  actions.setBabelPlugin({
    name: '@babel/plugin-proposal-export-default-from',
  });
  // add this
  actions.setBabelPlugin({
    name: '@babel/plugin-proposal-nullish-coalescing-operator',
  });
};