lorenseanstewart / nextjs-mdx-blog-kit

Starter code for creating a static blog system using Next.js and MDX. A service worker for offline reading is set up, and the blog has Perfect Lighthouse scores.

Home Page:https://nextjs-mdx-blog-kit.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Yarn build fails

rjain15 opened this issue · comments

I have updated the package.json with the following dependencies

{
    "name": "next-mdx-static-blog-kit",
    "version": "1.0.0",
    "description": "A starter kit for creating a static website blog using Next.js and MDX",
    "scripts": {
        "dev": "NODE_ENV=development next",
        "build": "NODE_ENV=production next build",
        "build-dev": "NODE_ENV=development next build",
        "start": "NODE_ENV=production next start",
        "clean": "rm -rf .next ; npm ci ; NODE_ENV=development npm run dev",
        "now-build": "next build && next export -o dist",
        "test": "jest"
    },
    "keywords": [
        "next.js",
        "react.js",
        "blog",
        "mdx"
    ],
    "author": "Loren Stewart",
    "license": "ISC",
    "bin": {
        "blog": "cli.js"
    },
    "browserslist": [
        "last 2 version"
    ],
    "dependencies": {
        "@mdx-js/loader": "^1.0.16",
        "@next/mdx": "^8.1.0",
        "babel-plugin-preval": "^3.0.1",
        "babel-preset-env": "^1.7.0",
        "babel-preset-latest": "^6.24.1",
        "chalk": "^2.4.2",
        "js-yaml": "^3.13.1",
        "js-yaml-loader": "^1.0.1",
        "next": "^8.1.0",
        "next-fonts": "^0.17.0",
        "next-seo": "^1.11.2",
        "react": "^16.8.6",
        "react-anchor-link-smooth-scroll": "^1.0.12",
        "react-dom": "^16.8.6",
        "react-icons": "^3.6.1",
        "react-syntax-highlighter": "^10.2.1",
        "remark-emoji": "^2.0.2",
        "remark-images": "^0.18.0",
        "scrollprogress": "^3.0.2",
        "yargs": "^13.2.2"
    },
    "devDependencies": {
        "imagemin-gifsicle": "^6.0.1",
        "imagemin-mozjpeg": "^8.0.0",
        "imagemin-optipng": "^6.0.0",
        "imagemin-svgo": "^7.0.0",
        "jest": "^24.7.1",
        "next-optimized-images": "^2.5.0",
        "svg-sprite-loader": "^4.1.6",
        "webp-loader": "^0.4.0"
    }
}

Here is my babelrc

{
    "presets": [  "latest",    "next/babel"],
    "plugins": ["preval"]
}

And this is the error I am running into

❯ yarn run build
yarn run v1.13.0
$ NODE_ENV=production next build
Creating an optimized production build ...

> Using external babel configuration
> Location: "/Users/rjain/code/jamstack/hello-mdx-nextjs/.babelrc"
Failed to compile.

./pages/index.mdx
TypeError: Cannot read property 'bindings' of null

If I didn't put latest in the babelrc presets, I am running into other issues

❯ yarn run build
yarn run v1.13.0
$ NODE_ENV=production next build
Creating an optimized production build ...

> Using external babel configuration
> Location: "/Users/rjain/code/jamstack/hello-mdx-nextjs/.babelrc"
> Build error occurred
/Users/rjain/code/jamstack/hello-mdx-nextjs/node_modules/react-syntax-highlighter/dist/esm/styles/prism/index.js:1
export { default as coy } from './coy';
^^^^^^

SyntaxError: Unexpected token export
    at Module._compile (internal/modules/cjs/loader.js:703:23)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:770:10)
    at Module.load (internal/modules/cjs/loader.js:628:32)
    at Function.Module._load (internal/modules/cjs/loader.js:555:12)
    at Module.require (internal/modules/cjs/loader.js:666:19)
    at require (internal/modules/cjs/helpers.js:16:16)
    at Object.Q9mJ (/Users/rjain/code/jamstack/hello-mdx-nextjs/.next/server/static/u7F6s_7UbBzF_sCrck0CA/pages/blog/post-one-code-block-demo.js:817:18)
    at __webpack_require__ (/Users/rjain/code/jamstack/hello-mdx-nextjs/.next/server/static/u7F6s_7UbBzF_sCrck0CA/pages/blog/post-one-code-block-demo.js:23:31)
    at Module.249+ (/Users/rjain/code/jamstack/hello-mdx-nextjs/.next/server/static/u7F6s_7UbBzF_sCrck0CA/pages/blog/post-one-code-block-demo.js:170:14)
    at __webpack_require__ (/Users/rjain/code/jamstack/hello-mdx-nextjs/.next/server/static/u7F6s_7UbBzF_sCrck0CA/pages/blog/post-one-code-block-demo.js:23:31)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Sorry, I don't use yarn so I'm not sure how to fix your problem. If you figure it out, feel free to make a PR on the project README that includes instructions for use with yarn.