histoire-dev / histoire-dev/histoire

The requested module 'eventemitter2' is a CommonJS module, which may not support all module.exports as named exports.

Open
#488 9 comments 1 reaction 0 assignees View on GitHub
to triage
Dominant language
TypeScript
Stars
3.6k
Forks
212
PR merge metrics
No merged PRs in 30d

Description

### Describe the bug

I am trying to introduce historie in our pnpm project, I am running into tje following message while collecting story.

I think this might be due to the `eventemitter2` package problems, but I am not sure how to solve this.
```
Error while collecting story xxx/xxx/xxx/XTable.story.vue:
file:///C:/Users/xxxxx/Documents/frontend/xxx/packages/emitter/dist/index.mjs:1
import { EventEmitter2 } from "eventemitter2";
^^^^^^^^^^^^^
SyntaxError: Named export 'EventEmitter2' not found. The requested module 'eventemitter2' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from 'eventemitter2';
const { EventEmitter2 } = pkg;
```
here's the `historie.config.ts` setting

```javascript
import { defineConfig } from 'histoire';
import { HstVue } from '@histoire/plugin-vue';

export default defineConfig({
plugins: [HstVue()],
setupFile: './histoire.setup.ts',
});
```

### Reproduction

May not be able to reproduce this considering this is a problem due to the packages.

### System Info

```shell
System:
OS: Windows 10 10.0.22000
CPU: (12) x64 Intel(R) Core(TM) i7-10810U CPU @ 1.10GHz
Memory: 12.20 GB / 31.80 GB
Binaries:
Node: 16.19.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.19 - ~\node_modules\.bin\yarn.CMD
npm: 8.19.3 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: Spartan (44.22000.120.0), Chromium (111.0.1661.44)
Internet Explorer: 11.0.22000.120
npmPackages:
@histoire/plugin-vue: ^0.15.8 => 0.15.8
histoire: ^0.15.8 => 0.15.8
vite: ^2.0.0 => 2.9.8
```

### Used Package Manager

pnpm

### Validations

- [X] Follow our [Code of Conduct](https://github.com/histoire-dev/histoire/blob/main/CODE_OF_CONDUCT.md)
- [X] Read the [Contributing Guidelines](https://github.com/histoire-dev/histoire/blob/main/CONTRIBUTING.md).
- [X] Read the [docs](https://histoire.dev/guide/).
- [X] Check that there isn't [already an issue](https://github.com/histoire-dev/histoire/issues) that reports the same bug to avoid creating a duplicate.
- [X] Check that this is a concrete bug. For Q&A open a [GitHub Discussion](https://github.com/histoire-dev/histoire/discussions).
- [X] The provided reproduction is a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) of the bug.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.