question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Module build failed (from ./node_modules/@mdx-js/loader/index.js)

See original GitHub issue

Describe the bug Everything worked fine until in and MDX file I’ve added a new story. In other MDX files stories work fine.

The error message is:

Module build failed (from ./node_modules/@mdx-js/loader/index.js):
SyntaxError: Unexpected token (1:62)
    at Object.raise (/home/cs/work/react-best-practices/node_modules/@storybook/addon-docs/node_modules/@babel/parser/lib/index.js:6325:17)
    at Object.unexpected (/home/cs/work/react-best-practices/node_modules/@storybook/addon-docs/node_modules/@babel/parser/lib/index.js:7642:16)
    at Object.getExpression (/home/cs/work/react-best-practices/node_modules/@storybook/addon-docs/node_modules/@babel/parser/lib/index.js:8125:12)
    at Object.parseExpression (/home/cs/work/react-best-practices/node_modules/@storybook/addon-docs/node_modules/@babel/parser/lib/index.js:11316:17)
    at getExports (/home/cs/work/react-best-practices/node_modules/@storybook/addon-docs/dist/mdx/mdx-compiler-plugin.js:257:26)
    at /home/cs/work/react-best-practices/node_modules/@storybook/addon-docs/dist/mdx/mdx-compiler-plugin.js:304:19
    at Array.forEach ()
    at extractExports (/home/cs/work/react-best-practices/node_modules/@storybook/addon-docs/dist/mdx/mdx-compiler-plugin.js:303:17)
    at Compiler (/home/cs/work/react-best-practices/node_modules/@storybook/addon-docs/dist/mdx/mdx-compiler-plugin.js:364:14)
    at Function.stringify (/home/cs/work/react-best-practices/node_modules/unified/index.js:344:12)
    at pipelineStringify (/home/cs/work/react-best-practices/node_modules/unified/index.js:40:25)
    at wrapped (/home/cs/work/react-best-practices/node_modules/trough/wrap.js:25:19)
    at next (/home/cs/work/react-best-practices/node_modules/trough/index.js:57:24)
    at done (/home/cs/work/react-best-practices/node_modules/trough/wrap.js:55:16)
    at done (/home/cs/work/react-best-practices/node_modules/unified/index.js:34:7)
    at done (/home/cs/work/react-best-practices/node_modules/unified/index.js:304:11)

./src/components/ThinkingInReact/ThinkingInReact.stories.mdx@http://localhost:9009/main.0bbc0897561a87b9ac64.bundle.js:7044:7
__webpack_require__@http://localhost:9009/runtime~main.0bbc0897561a87b9ac64.bundle.js:786:30
fn@http://localhost:9009/runtime~main.0bbc0897561a87b9ac64.bundle.js:151:20
webpackContext@http://localhost:9009/main.0bbc0897561a87b9ac64.bundle.js:41:9
loadStories/

To Reproduce Steps to reproduce the behavior:

  1. Go to https://github.com/metamn/react-best-practices/releases/tag/v0.0.2
  2. Download the release frozen to keep the bug
  3. Install locally and run storybook
  4. See error

Expected behavior It should display the new story as the other stories in the past

Screenshots Screenshot from 2019-09-01 13-42-33

Code snippets This is the component: src/components/ThinkingInReact/ThinkingInReact.js This is the MDX file: src/components/ThinkingInReact/ThinkingInReact.stories.mdx This is the story:

<Preview>
  <Story name="Pure component">
    <PureComponent param1="String" param2={true} />
  </Story>
</Preview>

System:

Environment Info:

  System:
    OS: Linux 4.15 Ubuntu 18.04.3 LTS (Bionic Beaver)
    CPU: (4) x64 Intel(R) Core(TM) i5-7Y54 CPU @ 1.20GHz
  Binaries:
    Node: 10.16.3 - /usr/local/bin/node
    Yarn: 1.9.4 - /usr/bin/yarn
    npm: 6.9.0 - /usr/local/bin/npm
  Browsers:
    Chrome: 70.0.3538.77
    Firefox: 68.0.2
  npmPackages:
    @storybook/addon-actions: ^5.2.0-rc.2 => 5.2.0-rc.2 
    @storybook/addon-docs: ^5.2.0-rc.2 => 5.2.0-rc.2 
    @storybook/addon-links: ^5.2.0-rc.2 => 5.2.0-rc.2 
    @storybook/addons: ^5.2.0-rc.2 => 5.2.0-rc.2 
    @storybook/react: ^5.2.0-rc.2 => 5.2.0-rc.2 
    @storybook/storybook-deployer: ^2.8.1 => 2.8.1 

Additional context Add any other context about the problem here.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:5
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
shilmancommented, Sep 28, 2019
0reactions
stopyranskycommented, Feb 12, 2022

having the same issue here and using nrwl/nx. After applying additional config it fails with following warnings:

> nx run shared-ui:storybook 
info => Loading presets
info Found existing addon {"name":"@storybook/addon-docs","options":{"configureJSX":true,"babelOptions":{},"sourceLoaderOptions":null,"transcludeMarkdown":true}}, skipping.
info => Loading Nrwl React Storybook preset from "@nrwl/react/plugins/storybook"
info => Using default Webpack5 setup
<i> [webpack-dev-middleware] wait until bundle finished
WARN Expected '@storybook/addon-docs' (or '@storybook/addon-essentials') to be listed before '@storybook/addon-controls' (or '@storybook/addon-essentials') in main Storybook config.
Read more comments on GitHub >

github_iconTop Results From Across the Web

16 - Stack Overflow
main.js Module build failed (from ./node_modules/babel-loader/lib/index.js): Error: Cannot find module 'babel-preset-es2015' from ...
Read more >
Bug Report - GitHub
Bug Report Current Behavior when i try to run the command npm start i get that error : ERROR in ./main.js Module build...
Read more >
Your browser can't play this video. Learn more - YouTube
Module build failed (from ./node_modules/source-map-loader/dist/cjs. js ): Error: ENOENT: no such file or directory, ...
Read more >
Get Help and Help Others - RedwoodJS Community
Compiled with problems:X ERROR in ./src/components/Button/Button.tsx Module build failed (from ../node_modules/babel-loader/lib/index.js):.
Read more >
Angular - Code with Mosh Forum
src/main.ts - Error: Module build failed (from ./node_modules/@ngtools/webpack/src/ivy/index.js): Error: Emit ./src/polyfills.ts - Error: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found