Search code examples
javascriptreactjsnpmnext.jsstorybook

Why I'm getting EBUSY: resource busy or locked, open errno: -4082 error when build storybook 7 in next.js 13?


I want to build storybook but I got this error in my project:

[Error: EBUSY: resource busy or locked, open 'C:\Users\ali\Desktop\Works\Design Systems\projects\storybook-test2\node_modules\.cache\storybook\dev-server\a5a8bf6e622aef57065c6498611f40c911543d7d-a21314dc303cf26dabba6bf4a8fd381e47e44e94'] {
  errno: -4082,
  code: 'EBUSY',
  syscall: 'open',
  path: 'C:\\Users\\ali\\Desktop\\Works\\Design Systems\\projects\\storybook-test2\\node_modules\\.cache\\storybook\\dev-server\\a5a8bf6e622aef57065c6498611f40c911543d7d-a21314dc303cf26dabba6bf4a8fd381e47e44e94'
}

I cleared cache files then tried again build but it didn't work. How can I solve this problem? My packacge.json details:

{
  "name": "storybook-test2",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint",
    "storybook": "storybook dev -p 6006",
    "build-storybook": "storybook build"
  },
  "dependencies": {
    "@types/node": "20.5.9",
    "@types/react": "18.2.21",
    "@types/react-dom": "18.2.7",
    "eslint": "8.48.0",
    "eslint-config-next": "13.4.19",
    "next": "13.4.19",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "typescript": "5.2.2"
  },
  "devDependencies": {
    "@storybook/addon-essentials": "^7.4.0",
    "@storybook/addon-interactions": "^7.4.0",
    "@storybook/addon-links": "^7.4.0",
    "@storybook/addon-onboarding": "^1.0.8",
    "@storybook/blocks": "^7.4.0",
    "@storybook/nextjs": "^7.4.0",
    "@storybook/react": "^7.4.0",
    "@storybook/testing-library": "^0.2.0",
    "eslint-plugin-storybook": "^0.6.13",
    "storybook": "^7.4.0"
  }
}


Solution

  • I solved the problem with two steps.

    1. I reinstalled node
    2. I added the code snippet below to the .storybook/main.ts file

    webpack: (config, options) => { options.cache.set = () => Promise.resolve(); return config; }