histoire-dev / histoire-dev/histoire
Error: Cannot find module
- Dominant language
- TypeScript
- Stars
- 3.6k
- Forks
- 212
- PR merge metrics
- No merged PRs in 30d
Description
### Describe the bug
I have a Nuxt project in which I have error.vue file and it uses @datadog/browser-rum library to record the sample sessions. When I run histoire build command it throws following error:
I am not even using error.vue file in histoire but it is automatically calling it in a build.
```
Error while collecting story /home/exampleFile.story.vue:
Error: Cannot find module /home/user/node_modules/@datadog/browser-rum/esm imported from file:///home/username/repo, file:///home/username/, file:///home/username/repo/_index.js, file:///home/username/node_modules
at _resolve (file:///home/username/repo/node_modules/mlly/dist/index.mjs:2107:19)
at resolveSync (file:///home/username/repo/node_modules/mlly/dist/index.mjs:2116:10)
at resolvePathSync (file:///home/username/repo/node_modules/mlly/dist/index.mjs:2126:24)
at resolvePath (file:///home/username/repo/node_modules/mlly/dist/index.mjs:2130:28)
at isValidNodeImport (file:///home/username/repo/node_modules/mlly/dist/index.mjs:2602:30)
at _shouldExternalize (file:///home/username/repo/node_modules/histoire/node_modules/vite-node/dist/server.mjs:78:32)
at shouldExternalize (file:///home/username/repo/node_modules/histoire/node_modules/vite-node/dist/server.mjs:55:19)
at ViteNodeServer.shouldExternalize (file:///home/username/repo/node_modules/histoire/node_modules/vite-node/dist/server.mjs:225:12)
at ViteNodeServer._fetchModule (file:///home/username/repo/node_modules/histoire/node_modules/vite-node/dist/server.mjs:322:36)
at ViteNodeServer.fetchModule (file:///home/username/repo/node_modules/histoire/node_modules/vite-node/dist/server.mjs:261:14)
at Object.fetchModule (file:///home/username/repo/node_modules/histoire/dist/node/collect/index.js:50:37)
at MessagePort. (file:///home/username/repo/node_modules/birpc/dist/index.mjs:16:41)
at [nodejs.internal.kHybridDispatch] (node:internal/event_target:761:20)
at exports.emitMessage (node:internal/per_context/messageport:23:28)
```
I have tried to add following in histoire.config.ts but still same issue:
```
export default defineConfig({
plugins: [HstVue(), HstNuxt()],
storyIgnored: ['**/node_modules/**', '**/dist/**', 'error.vue'],
})
```
### Reproduction
Install @datadog/browser-rum library and call it in a error.vue file and run yarn histoire build command
### System Info
```shell
I am using Nuxt3 and versions are as follows:
"@histoire/plugin-nuxt": "^0.17.8"
"@histoire/plugin-vue": "^0.17.8"
"histoire": "^0.17.8"
"@datadog/browser-rum": "^5.9.0"
```
### Used Package Manager
yarn
### 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
Research direction
Start with the histoire.config.ts configuration and the error.vue reproduction described in the issue. Install @datadog/browser-rum, run yarn histoire build, and inspect how story collection handles the Nuxt error page and external module resolution. Done means the minimal reproduction builds without the Cannot find module error while preserving normal story collection.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nuxt, typescript, vite
- Domain
- build-system, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100