Search code examples
reactjstypescriptproxyvitestorybook

Storybook - TypeError: Invalid URL


Whenever I run a storybook command I get this error :

/Users/f38062/.npm/_npx/bc7e1e37fcb46ffc/node_modules/@storybook/cli/bin/index.js:23
  throw error;
  ^

TypeError: Invalid URL
    at new URL (node:internal/url:783:36)
    at new ProxyAgent (/Users/f38062/.npm/_npx/bc7e1e37fcb46ffc/node_modules/node-fetch-native/dist/proxy.cjs:47:43015)
    at new UndiciProxyAgent (/Users/f38062/.npm/_npx/bc7e1e37fcb46ffc/node_modules/node-fetch-native/dist/proxy.cjs:60:1383)
    at createProxy (/Users/f38062/.npm/_npx/bc7e1e37fcb46ffc/node_modules/node-fetch-native/dist/proxy.cjs:60:3063)
    at createFetch (/Users/f38062/.npm/_npx/bc7e1e37fcb46ffc/node_modules/node-fetch-native/dist/proxy.cjs:60:3210)
    at Object.<anonymous> (/Users/f38062/.npm/_npx/bc7e1e37fcb46ffc/node_modules/node-fetch-native/dist/proxy.cjs:60:3345)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12) {
  code: 'ERR_INVALID_URL',
  input: '127.0.0.1:8079'
}

Node.js v21.2.0

My guess is that it comes from my enterprise proxy but we never faced this issue before and now any storybook command fails with this output.

I tried deleting and re-installing storybook

I tried to search online for similar issues but found none


Solution

  • Maybe check your .zshrc if your on Mac, Storybook or Vite can use the export http_proxy or https_proxy to force the port to a different one than the default 6006. This solution worked for me.