#Storybook + Vite no loader is configured for .node files

2 messages · Page 1 of 1 (latest)

astral blaze
#

I'm trying to setup Storybook 8.2 with Vite. Here is my storybook config:

import type { StorybookConfig } from "@storybook/react-vite";

import { nxViteTsPaths } from "@nx/vite/plugins/nx-tsconfig-paths.plugin";
import { mergeConfig } from "vite";
import { UserConfig } from "vite";

const config: StorybookConfig = {
  stories: ["../../../../packages/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
  framework: {
    name: "@storybook/react-vite",
    options: {
      builder: {
        viteConfigPath: "../../../vite.config.ts"
      }
    }
  },
  refs: {
    next: {
      title: "Next.js",
      url: "http://localhost:7007"
    }
  },
  viteFinal: async (config: UserConfig) =>
    mergeConfig(config, {
      plugins: [nxViteTsPaths()],
      build: {
        rollupOptions: {
          external: [
            "universal-fs",
            "packages/etech-ui-utils/**",
            "@ngrok/ngrok-darwin-arm64",
            "@ngrok/ngrok-darwin-universal"
          ]
        }
      }
    })
};

export default config;

However, when running npx storybook dev I get an error:

✘ [ERROR] No loader is configured for ".node" files: 

    ../../../node_modules/.pnpm/@[email protected]/node_modules/@ngrok/ngrok

✘ [ERROR] No loader is configured for ".node" files: ../../../node_modules/.pnpm/@[email protected]/node_modules/@ngrok/ngrok-darwin-universal/ngrok.darwin-universal.node                                

It's worth noting that I'm in an NX monorepo this storybook is nested in apps/storybook/vite-react. There are other dependencies that are problematic so I'm trying to ignore them with rollup options. However, I still get the error.

I have tried several Github suggestions without luck. Essentialy I want Vite to only watch where stories are found. How can I do that?

timid moth
#

I think this is a bit too storybook specific, so asking on their side might be better.
Having said that, from what I know on Vite, the message No loader is configured for ".node" is likely due to Vite's esbuild based dev-time bundling picking up heavy server dependencies. I would assume those are meant to be tree-shaken away on Next.js app, but Vite is seeing that in import chain somehow.
optimizeDeps.exclude: ["@ngrok/ngrok"] would worth the try, but that might just move the error from dev startup to a runtime error during actual dev.
Not familiar with storybook, but maybe those deps are supposed to be mocked away?