Repository: storybook
Issue: Webpack 5 - EBUSY: resource busy or locked
Labels: bug,has workaround,angular,builder-webpack5,windows

Hi there @shilman !


Working on a project that uses Angular 12 and Webpack 5, it seems that i am the only user in the team that is getting this issue and we are afraid it might backfire for everyone else in one point. The encountered error is as follows, after running storybook:

`- Unhandled rejection Error: EBUSY: resource busy or locked, open 'C:\Users\fvasile\Documents\Storybook-template\taskbox\node_modules\.cache\storybook\dev-server\325c8f456729b912b0d2134054eb7448-41ac79ddc5290d504ad69ef1fe8200a7'`

To reproduce this issue, i have cloned a completely new instance of Storybook and have updated it with a couple of packages/libraries, and was able to reproduce the same issue. It seems that these following ones, or a combination of them, is causing the error:

"devDependencies":
    "@storybook/addon-actions": "^6.4.0-beta.14",
    "@storybook/addon-essentials": "^6.4.0-beta.14",
    "@storybook/addon-links": "^6.4.0-beta.14",
    "@storybook/angular": "^6.4.0-beta.14",
    "@storybook/builder-webpack5": "^6.4.0-beta.14",
    "@storybook/manager-webpack5": "^6.4.0-beta.14",
     "webpack": "^5.38.1",


**Currently using these following versions and a more complete outline of the packages:**
- node v14.18.1
- yarn 1.22.11
- npm 6.14.15
- "dependencies": {
    "@angular/animations": "12.1.4",
    "@angular/common": "12.1.4",
    "@angular/compiler": "12.1.4",
    "@angular/core": "12.1.4",
    "@angular/elements": "12.1.4",
    "@angular/forms": "12.1.4",
    "@angular/platform-browser": "12.1.4",
    "@angular/platform-browser-dynamic": "12.1.4",
    "@angular/router": "12.1.4",
    "@azure/msal-angular": "2.0.2",
    "@azure/msal-browser": "2.16.0",
    "@microsoft/signalr": "5.0.8",
    "@ngneat/until-destroy": "^8.0.3",
    "bootstrap": "5.0.2",
    "rxjs": "~6.6.7",
    "tslib": "^2.1.0",
    "webpack": "^5.38.1",
    "zone.js": "~0.11.4"
  },
-  "devDependencies": {
    "@angular-devkit/architect": "~0.1201.2",
    "@angular-devkit/build-angular": "12.1.4",
    "@angular-devkit/core": "12.1.4",
    "@angular/cli": "12.1.4",
    "@angular/compiler-cli": "12.1.4",
    "@babel/core": "^7.12.10",
    "@compodoc/compodoc": "^1.1.11",
    "@storybook/addon-actions": "^6.4.0-beta.14",
    "@storybook/addon-essentials": "^6.4.0-beta.14",
    "@storybook/addon-links": "^6.4.0-beta.14",
    "@storybook/addon-measure": "6.4.0-beta.14",
    "@storybook/angular": "^6.4.0-beta.14",
    "@storybook/builder-webpack5": "^6.4.0-beta.14",
    "@storybook/manager-webpack5": "^6.4.0-beta.14",
    "@types/jasmine": "^3.6.3",
    "@types/jest": "^27.0.2",
    "@types/node": "^16.4.6",
    "babel-loader": "^8.2.2",
    "concurrently": "^6.2.0",
    "jasmine-core": "~3.8.0",
    "jasmine-spec-reporter": "~7.0.0",
    "karma": "~6.3.3",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage": "~2.0.3",
    "karma-jasmine": "~4.0.0",
    "karma-jasmine-html-reporter": "^1.5.0",
    "ng-packagr": "^12.1.0",
    "prettier-plugin-organize-imports": "^2.3.3",
    "protractor": "~7.0.0",
    "scss-bundle": "^3.1.2",
    "ts-node": "~10.1.0",
    "typescript": "~4.3.5"
  },
  "engines": {
    "node": ">=14.15.4",
    "yarn": ">=1.22.10"
  }

**main.js file looks like this:**
```
module.exports = {
  core: {
    builder: "webpack5",
  },
  stories: [
    "../projects/**/*.stories.mdx",
    "../projects/**/*.stories.@(js|jsx|ts|tsx)",
  ],
  addons: ["@storybook/addon-links", "@storybook/addon-essentials"],
};
```


Developing on Windows 10. 

All in all, it seems that we have narrowed it down to a potential issue between Webpack 5 and Angular 12. Any help would be appreciated, let me know if you need more info. Thank you!