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.

ERROR in ./node_modules/cosmiconfig/dist/readFile.js

See original GitHub issue

Describe the bug Can’t Run Storybook without any error

Expected behavior Should Run Storybook without any error

Code snippets

import initStoryshots, {
  multiSnapshotWithOptions,
} from '@storybook/addon-storyshots'
import ReactDOM from 'react-dom'

ReactDOM.createPortal = element => element

initStoryshots({
  suite: 'Treehive',
  storyKindRegex: /^(?!.*noSnap)/,
  test: multiSnapshotWithOptions({}),
})

add package

    "@storybook/addon-knobs": "^5.1.3",
    "@storybook/addon-storyshots": "^5.1.3",
    "@storybook/addons": "^5.1.3",
    "@storybook/react": "^5.1.3",
    "react-testing-library": "^7.0.0",

Error Saying

webpack building...
webpack built 79e0ba451fb05f1f2ec8 in 1835ms                                                                            
✖ 「wdm」: Hash: 79e0ba451fb05f1f2ec8
Version: webpack 4.33.0
Time: 1835ms
Built at: 2019-06-11 14:16:15
                                          Asset       Size        Chunks                    Chunk Names
           37aee8c12a95cf739c17.hot-update.json   35 bytes                [emitted]         
                            asset-manifest.json  760 bytes                [emitted]         
                                    iframe.html   2.52 KiB                [emitted]         
            main.79e0ba451fb05f1f2ec8.bundle.js    143 KiB          main  [emitted]         main
        main.79e0ba451fb05f1f2ec8.bundle.js.map    144 KiB          main  [emitted]         main
    runtime~main.79e0ba451fb05f1f2ec8.bundle.js   31.1 KiB  runtime~main  [emitted]         runtime~main
runtime~main.79e0ba451fb05f1f2ec8.bundle.js.map   32.3 KiB  runtime~main  [emitted]         runtime~main
                static/media/cross.cf80a58f.svg  565 bytes                                  
            static/media/invalid-x.6de13895.svg  278 bytes                                  
             static/media/login-bg.a7dc4154.svg   3.01 KiB                                  
           static/media/tick_green.ffd384a3.svg  528 bytes                                  
    vendors~main.79e0ba451fb05f1f2ec8.bundle.js   2.63 MiB  vendors~main  [emitted]  [big]  vendors~main
vendors~main.79e0ba451fb05f1f2ec8.bundle.js.map   2.76 MiB  vendors~main  [emitted]         vendors~main
Entrypoint main [big] = runtime~main.79e0ba451fb05f1f2ec8.bundle.js runtime~main.79e0ba451fb05f1f2ec8.bundle.js.map vendors~main.79e0ba451fb05f1f2ec8.bundle.js vendors~main.79e0ba451fb05f1f2ec8.bundle.js.map main.79e0ba451fb05f1f2ec8.bundle.js main.79e0ba451fb05f1f2ec8.bundle.js.map
[0] multi ./node_modules/@storybook/core/dist/server/common/polyfills.js ./node_modules/@storybook/core/dist/server/preview/globals.js ./.storybook/config.js ./node_modules/webpack-hot-middleware/client.js?reload=true 64 bytes {main}
[./.storybook/config.js] 303 bytes {main}
[./node_modules/@storybook/core/dist/server/common/polyfills.js] 120 bytes {vendors~main}
[./node_modules/@storybook/core/dist/server/preview/globals.js] 93 bytes {vendors~main}
[./node_modules/@storybook/core/node_modules/webpack/buildin/harmony-module.js] (webpack)/buildin/harmony-module.js 573 bytes {vendors~main}
[./node_modules/@storybook/core/node_modules/webpack/buildin/module.js] (webpack)/buildin/module.js 497 bytes {vendors~main}
[./node_modules/@storybook/react/dist/client/index.js] 1.26 KiB {vendors~main}
[./node_modules/airbnb-js-shims/index.js] 40 bytes {vendors~main}
[./node_modules/core-js/features/symbol/index.js] 199 bytes {vendors~main}
[./node_modules/global/window.js] 232 bytes {vendors~main}
[./node_modules/querystring-es3/index.js] 127 bytes {vendors~main}
[./node_modules/regenerator-runtime/runtime.js] 23 KiB {vendors~main}
[./node_modules/require-context.macro/require-context.macro.js] 733 bytes {vendors~main}
[./node_modules/strip-ansi/index.js] 161 bytes {vendors~main}
[./node_modules/webpack-hot-middleware/client.js?reload=true] 7.68 KiB {vendors~main}
    + 619 hidden modules

WARNING in ./node_modules/babel-plugin-macros/dist/index.js 55:22-29
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
 @ ./node_modules/require-context.macro/require-context.macro.js
 @ ./.storybook/config.js
 @ multi ./node_modules/@storybook/core/dist/server/common/polyfills.js ./node_modules/@storybook/core/dist/server/preview/globals.js ./.storybook/config.js ./node_modules/webpack-hot-middleware/client.js?reload=true

WARNING in ./node_modules/import-fresh/index.js 28:8-25
Critical dependency: the request of a dependency is an expression
 @ ./node_modules/cosmiconfig/dist/loaders.js
 @ ./node_modules/cosmiconfig/dist/index.js
 @ ./node_modules/babel-plugin-macros/dist/index.js
 @ ./node_modules/require-context.macro/require-context.macro.js
 @ ./.storybook/config.js
 @ multi ./node_modules/@storybook/core/dist/server/common/polyfills.js ./node_modules/@storybook/core/dist/server/preview/globals.js ./.storybook/config.js ./node_modules/webpack-hot-middleware/client.js?reload=true

ERROR in ./node_modules/cosmiconfig/dist/readFile.js
Module not found: Error: Can't resolve 'fs' in '/Users/waseem/Desktop/th/node_modules/cosmiconfig/dist'
 @ ./node_modules/cosmiconfig/dist/readFile.js 4:11-24
 @ ./node_modules/cosmiconfig/dist/createExplorer.js
 @ ./node_modules/cosmiconfig/dist/index.js
 @ ./node_modules/babel-plugin-macros/dist/index.js
 @ ./node_modules/require-context.macro/require-context.macro.js
 @ ./.storybook/config.js
 @ multi ./node_modules/@storybook/core/dist/server/common/polyfills.js ./node_modules/@storybook/core/dist/server/preview/globals.js ./.storybook/config.js ./node_modules/webpack-hot-middleware/client.js?reload=true

ERROR in ./node_modules/is-directory/index.js
Module not found: Error: Can't resolve 'fs' in '/Users/waseem/Desktop/th/node_modules/is-directory'
 @ ./node_modules/is-directory/index.js 10:9-22
 @ ./node_modules/cosmiconfig/dist/getDirectory.js
 @ ./node_modules/cosmiconfig/dist/createExplorer.js
 @ ./node_modules/cosmiconfig/dist/index.js
 @ ./node_modules/babel-plugin-macros/dist/index.js
 @ ./node_modules/require-context.macro/require-context.macro.js
 @ ./.storybook/config.js
 @ multi ./node_modules/@storybook/core/dist/server/common/polyfills.js ./node_modules/@storybook/core/dist/server/preview/globals.js ./.storybook/config.js ./node_modules/webpack-hot-middleware/client.js?reload=true

ERROR in ./node_modules/resolve/lib/async.js
Module not found: Error: Can't resolve 'fs' in '/Users/waseem/Desktop/th/node_modules/resolve/lib'
 @ ./node_modules/resolve/lib/async.js 2:9-22
 @ ./node_modules/resolve/index.js
 @ ./node_modules/babel-plugin-macros/dist/index.js
 @ ./node_modules/require-context.macro/require-context.macro.js
 @ ./.storybook/config.js
 @ multi ./node_modules/@storybook/core/dist/server/common/polyfills.js ./node_modules/@storybook/core/dist/server/preview/globals.js ./.storybook/config.js ./node_modules/webpack-hot-middleware/client.js?reload=true

ERROR in ./node_modules/resolve/lib/sync.js
Module not found: Error: Can't resolve 'fs' in '/Users/waseem/Desktop/th/node_modules/resolve/lib'
 @ ./node_modules/resolve/lib/sync.js 2:9-22
 @ ./node_modules/resolve/index.js
 @ ./node_modules/babel-plugin-macros/dist/index.js
 @ ./node_modules/require-context.macro/require-context.macro.js
 @ ./.storybook/config.js
 @ multi ./node_modules/@storybook/core/dist/server/common/polyfills.js ./node_modules/@storybook/core/dist/server/preview/globals.js ./.storybook/config.js ./node_modules/webpack-hot-middleware/client.js?reload=true

ERROR in ./node_modules/resolve-from/index.js
Module not found: Error: Can't resolve 'module' in '/Users/waseem/Desktop/th/node_modules/resolve-from'
 @ ./node_modules/resolve-from/index.js 3:15-32
 @ ./node_modules/import-fresh/index.js
 @ ./node_modules/cosmiconfig/dist/loaders.js
 @ ./node_modules/cosmiconfig/dist/index.js
 @ ./node_modules/babel-plugin-macros/dist/index.js
 @ ./node_modules/require-context.macro/require-context.macro.js
 @ ./.storybook/config.js
 @ multi ./node_modules/@storybook/core/dist/server/common/polyfills.js ./node_modules/@storybook/core/dist/server/preview/globals.js ./.storybook/config.js ./node_modules/webpack-hot-middleware/client.js?reload=true

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:19

github_iconTop GitHub Comments

15reactions
Dammmiencommented, Sep 10, 2019

To solve this issue you have to install the babel-plugin-macros:

yarn add babel-plugin-macros --dev

Then add a .babelrc file to your root directory:

{
  "plugins": ["macros"]
}
1reaction
mAAdhaTTahcommented, Jun 15, 2019

Thanks, but I was on 3.0.1 at the time (it’s a new project). I cut out Storyshots for now and will have to revisit this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Module not found: Can't resolve 'fs' in Next.js application
Unable to identify what's happening in my next.js app. As fs is a default file system module of nodejs. It is giving the...
Read more >
How To Solve Module Not Found Can't Resolve 'fs' in Next.js
js project, I encountered the following error: Module not found: Can't resolve 'fs'. While this is a seemingly clear error, the quest for...
Read more >
Next.js + Webpack - Fix for ModuleNotFoundError: Module ...
To fix the error with Webpack 5, update your Next.js config file ( /next.config.js ) with the following, it tells webpack not to...
Read more >
CommonJS modules | Node.js v19.3.0 Documentation
Node.js has two module systems: CommonJS modules and ECMAScript modules. By default, Node.js ... Attempting to do so will throw a ERR_REQUIRE_ESM error....
Read more >
15 Common Error Codes in Node.js and How to Fix Them
Therefore, we've compiled this list of 15 common Node.js errors along ... On Linux, clearing the DNS cache depends on the distribution and ......
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