Skip to content

[Bug] package has "type": "module", but only commonjs is published, causing problems #21

Open
@dylang

Description

@dylang

Describe the bug

A clear and concise description of what the bug is.

Steps to reproduce the behavior

  1. https://www.npmjs.com/package/storybook-solidjs-vite?activeTab=code
  2. In the package.json is "type": "module" and there is "import": "./dist/preset.mjs".
  3. There's a file called storybook-solidjs-vite/dist/preset.js that contains commonjs (module.exports).
  4. There's no file named storybook-solidjs-vite/dist/preset.mjs.

Resulting error in Node 22:

[SB] info => Cleaning outputDir: storybook-static
[SB] info => Loading presets
[SB] SB_CORE-SERVER_0002 (CriticalPresetLoadError): Storybook failed to load the following preset: storybook-solidjs-vite/preset.
[SB] 
[SB] Please check whether your setup is correct, the Storybook dependencies (and their peer dependencies) are installed correctly and there are no package version clashes.
[SB] 
[SB] If you believe this is a bug, please open an issue on Github.
[SB] 
[SB] ReferenceError: module is not defined
[SB]     at file:///project/node_modules/.pnpm/storybook-solidjs-vite@1.0.0-beta.6_@testing-library+jest-dom@6.6.3_solid-js@1.9.5_stor_9bc8418f99ab4125250afe575d87f224/node_modules/storybook-solidjs-vite/dist/preset.js:1:1009
[SB]     at ModuleJobSync.runSync (node:internal/modules/esm/module_job:395:35)
[SB]     at ModuleLoader.importSyncForRequire (node:internal/modules/esm/loader:360:47)
[SB]     at loadESMFromCJS (node:internal/modules/cjs/loader:1385:24)
[SB]     at Module._compile (node:internal/modules/cjs/loader:1536:5)
[SB]     at node:internal/modules/cjs/loader:1706:10
[SB]     at Object.newLoader (/project/node_modules/.pnpm/esbuild-register@3.6.0_esbuild@0.25.0/node_modules/esbuild-register/dist/node.js:2262:9)
[SB]     at extensions..js (/project/node_modules/.pnpm/esbuild-register@3.6.0_esbuild@0.25.0/node_modules/esbuild-register/dist/node.js:4833:24)
[SB]     at Module.load (node:internal/modules/cjs/loader:1289:32)
[SB]     at Function._load (node:internal/modules/cjs/loader:1108:12)

Expected behavior

Either change package.json type to commonjs or publish the code as a module.

Screenshots and/or logs

Shown above

Environment

  • OS: MacOS, Linux
  • Node.js version: 22
  • NPM version: pnpm 10

Additional context

I wasn't able to reproduce this with the example in this repo, maybe because of how the yarn monorepo works and the source being available.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions