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.

'default' is not exported by babel-runtime define-property.js

See original GitHub issue

trying to build storybook (i can watch storybook which is a milestone we achieved) getting this error. some of my components do actually load babel-runtime (like https://github.com/react-component/calendar and others). so I can’t just bump to @babel/runtime. not sure even if it will help. that’s might related to how rollup bundles common js modules. but I’m not sure.

'default' is not exported by node_modules/babel-runtime/node_modules/core-js/library/fn/object/define-property.js?commonjs-proxy, imported by ../node_modules/babel-runtime/core-js/object/define-property.js
file: node_modules/babel-runtime/core-js/object/define-property.js:4:7
2: import { __module as definePropertyModule, exports as defineProperty } from "\u0000node_modules/babel-runtime/core-js/object/define-property.js?commonjs-module"
3: import "\u0000core-js/library/fn/object/define-property?commonjs-require";
4: import require$$0 from "\u0000core-js/library/fn/object/define-property?commonjs-proxy";
^
5:
6: (function (module) {
  ERR! Error: 'default' is not exported by node_modules/babel-runtime/node_modules/core-js/library/fn/object/define-property.js?commonjs-proxy, imported by ../node_modules/babel-runtime/core-js/object/define-property.js
  ERR!     at error (node_modules/vite/node_modules/rollup/dist/shared/rollup.js:158:30)
  ERR!     at Module.error (node_modules/vite/node_modules/rollup/dist/shared/rollup.js:12382:16)
  ERR!     at Module.traceVariable (node_modules/vite/node_modules/rollup/dist/shared/rollup.js:12767:29)
  ERR!     at ModuleScope.findVariable (node_modules/vite/node_modules/rollup/dist/shared/rollup.js:11559:39)
  ERR!     at FunctionScope.findVariable (node_modules/vite/node_modules/rollup/dist/shared/rollup.js:6930:38)
  ERR!     at ChildScope.findVariable (node_modules/vite/node_modules/rollup/dist/shared/rollup.js:6930:38)
  ERR!     at Identifier.bind (node_modules/vite/node_modules/rollup/dist/shared/rollup.js:6419:40)
  ERR!     at Property.bind (node_modules/vite/node_modules/rollup/dist/shared/rollup.js:5025:23)
  ERR!     at ObjectExpression.bind (node_modules/vite/node_modules/rollup/dist/shared/rollup.js:5021:31)
  ERR!     at AssignmentExpression.bind (node_modules/vite/node_modules/rollup/dist/shared/rollup.js:5025:23)
  ERR!     at ExpressionStatement.bind (node_modules/vite/node_modules/rollup/dist/shared/rollup.js:5025:23)
  ERR!     at BlockStatement.bind (node_modules/vite/node_modules/rollup/dist/shared/rollup.js:5021:31)
  ERR!     at FunctionExpression.bind (node_modules/vite/node_modules/rollup/dist/shared/rollup.js:5025:23)
  ERR!     at CallExpression.bind (node_modules/vite/node_modules/rollup/dist/shared/rollup.js:5025:23)
  ERR!     at CallExpression.bind (node_modules/vite/node_modules/rollup/dist/shared/rollup.js:9396:15)
  ERR!     at ExpressionStatement.bind (node_modules/vite/node_modules/rollup/dist/shared/rollup.js:5025:23)
  ERR!  Error: 'default' is not exported by node_modules/babel-runtime/node_modules/core-js/library/fn/object/define-property.js?commonjs-proxy, imported by ../node_modules/babel-runtime/core-js/object/define-property.js
  ERR!     at error (node_modules/vite/node_modules/rollup/dist/shared/rollup.js:158:30)
  ERR!     at Module.error (node_modules/vite/node_modules/rollup/dist/shared/rollup.js:12382:16)
  ERR!     at Module.traceVariable (node_modules/vite/node_modules/rollup/dist/shared/rollup.js:12767:29)
  ERR!     at ModuleScope.findVariable (node_modules/vite/node_modules/rollup/dist/shared/rollup.js:11559:39)
  ERR!     at FunctionScope.findVariable (node_modules/vite/node_modules/rollup/dist/shared/rollup.js:6930:38)
  ERR!     at ChildScope.findVariable (node_modules/vite/node_modules/rollup/dist/shared/rollup.js:6930:38)
  ERR!     at Identifier.bind (node_modules/vite/node_modules/rollup/dist/shared/rollup.js:6419:40)
  ERR!     at Property.bind (node_modules/vite/node_modules/rollup/dist/shared/rollup.js:5025:23)
  ERR!     at ObjectExpression.bind (node_modules/vite/node_modules/rollup/dist/shared/rollup.js:5021:31)
  ERR!     at AssignmentExpression.bind (node_modules/vite/node_modules/rollup/dist/shared/rollup.js:5025:23)
  ERR!     at ExpressionStatement.bind (node_modules/vite/node_modules/rollup/dist/shared/rollup.js:5025:23)
  ERR!     at BlockStatement.bind (node_modules/vite/node_modules/rollup/dist/shared/rollup.js:5021:31)
  ERR!     at FunctionExpression.bind (node_modules/vite/node_modules/rollup/dist/shared/rollup.js:5025:23)
  ERR!     at CallExpression.bind (node_modules/vite/node_modules/rollup/dist/shared/rollup.js:5025:23)
  ERR!     at CallExpression.bind (node_modules/vite/node_modules/rollup/dist/shared/rollup.js:9396:15)
  ERR!     at ExpressionStatement.bind (node_modules/vite/node_modules/rollup/dist/shared/rollup.js:5025:23) {
    ERR!   code: 'MISSING_EXPORT',
      ERR!   url: 'https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module',
      ERR!   id: 'node_modules/babel-runtime/core-js/object/define-property.js',
      ERR!   pos: 336,
      ERR!   loc: {
      ERR!     column: 7,
        ERR!     file: 'node_modules/babel-runtime/core-js/object/define-property.js',
        ERR!     line: 4
      ERR!   },
    ERR!   frame: '2: import { __module as definePropertyModule, exports as defineProperty } from "\\u0000node_modules/babel-runtime/core-js/object/define-property.js?commonjs-module"\n' +
    ERR!     '3: import "\\u0000core-js/library/fn/object/define-property?commonjs-require";\n' +
    ERR!     '4: import require$$0 from "\\u0000core-js/library/fn/object/define-property?commonjs-proxy";\n' +
    ERR!     '          ^\n' +
    ERR!     '5: \n' +
    ERR!     '6: (function (module) {',
      ERR!   watchFiles: [
      ERR!     'storybook/iframe.html',
      ERR!     '/virtual:/@storybook/builder-vite/vite-app.js',
      ERR!     'vite/modulepreload-polyfill',
      ERR!     'node_modules/@storybook/react/dist/esm/client/index.js',
      ERR!     'node_modules/@storybook/client-api/dist/esm/index.js',
      ERR!     ... 2676 more items
      ERR!   ]
    ERR! }

using the latest vite and storybook-builder-vite and storybook “6.4.0-beta.25”

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
ZeekoZhucommented, Feb 28, 2022

I finally find a workaround for this issue. I’m using lingui@2.x, which has babel-runtime as a dependency, and this issue occurs.

  1. add core-js and other cjs modules to optimizeDeps
const { glob } = require('glob');

// we need to upgrade lingui to 3.x to remove the following config, they all come from lingui 2.x
const coreJsFiles = glob.sync('node_modules/core-js/modules/*.js').map(it => it.substring('node_modules/'.length));
const optimizeDeps = ['hoist-non-react-statics', ...coreJsFiles, '@lingui/core', '@lingui/react'];
  1. remove mock-core-js plugin
  viteFinal: async (config) => {
    if (config.optimizeDeps) {
      config.optimizeDeps.include.push(...optimizeDeps);
    } else {
      config.optimizeDeps = {
        include: optimizeDeps
      };
    }
    // remove the built-in mock-core-js
    const plugins = config.plugins.filter((_, i) => i !== 1);
    config.plugins = plugins;
   // other configs
    return config;
  },
1reaction
cain-wangcommented, Jan 26, 2022

Hi, I’m curious if we have any updates on that? We were able to get storybook local development working, but build-storybook still fails with similar errors.

'default' is not exported by xxx/node_modules/babel-runtime/node_modules/core-js/library/fn/object/keys.js?commonjs-proxy, imported by node_modules/babel-runtime/core-js/object/keys.js
xxx/node_modules/babel-runtime/core-js/object/keys.js:4:7
2: import { __module as keysModule, exports as keys } from "xxx/node_modules/babel-runtime/core-js/object/keys.js?commonjs-module"
3: import "\u0000core-js/library/fn/object/keys?commonjs-require";
4: import require$$0 from "\u0000core-js/library/fn/object/keys?commonjs-proxy";
          ^
5:
6: (function (module) {
Read more comments on GitHub >

github_iconTop Results From Across the Web

'default' is not exported by babel-runtime define-property.js ...
trying to build storybook (i can watch storybook which is a milestone we achieved) getting this error. some of my components do actually ......
Read more >
Rollup Error: 'default' is not exported by node_modules/react ...
js but I have trouble regarding the plugin @rollup/plugin-commonjs. My rollup.conf.js. import resolve from '@rollup/plugin-node-resolve'; ...
Read more >
rollup.js
It is bad practice to mix default and named exports in the same module, though it is allowed by the specification. How bindings...
Read more >
Frequently Asked Questions - Rollup Plugin Vue
Error: 'default' is not exported by node_modules/vue-runtime-helpers/dist/normalize-component.js. You may encounter this error when using version 4.6.2 ...
Read more >
@rollup/plugin-commonjs - npm package | Snyk
Security Policy: No. We found a way for you to contribute to the project! Looks like @rollup/plugin-commonjs is missing a security policy.
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