storybookjs / storybook

Storybook is the industry standard workshop for building, documenting, and testing UI components in isolation
https://storybook.js.org
MIT License
84.68k stars 9.32k forks source link

ModuleNotFoundError: Module not found #19827

Open anuuu16 opened 2 years ago

anuuu16 commented 2 years ago

Describe the bug

LOG:

`99% done plugins webpack-hot-middlewarewebpack built preview c15b371328b6edb107ca in 2357ms
ModuleNotFoundError: Module not found: Error: You attempted to import /Users/anu/Desktop/projects/pax-ui/client/node_modules/@storybook/client-api which falls outside of the project src/ directory. Relative imports outside of src/ are not supported.
You can either move it inside src/, or add a symlink to it from project's node_modules/.
    at /Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/Compilation.js:2016:28
    at /Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/NormalModuleFactory.js:798:13
    at eval (eval at create (/Users/anu/Desktop/projects/pax-ui/client/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:10:1)
    at /Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/NormalModuleFactory.js:270:22
    at eval (eval at create (/Users/anu/Desktop/projects/pax-ui/client/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:9:1)
    at /Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/NormalModuleFactory.js:434:22
    at /Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/NormalModuleFactory.js:116:11
    at /Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/NormalModuleFactory.js:670:25
    at /Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/NormalModuleFactory.js:855:8
    at /Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/NormalModuleFactory.js:975:5
ModuleNotFoundError: Module not found: Error: You attempted to import /Users/anu/Desktop/projects/pax-ui/client/node_modules/@storybook/preset-create-react-app/node_modules/@pmmmwh/react-refresh-webpack-plugin/lib/runtime/RefreshUtils.js which falls outside of the project src/ directory. Relative imports outside of src/ are not supported.
You can either move it inside src/, or add a symlink to it from project's node_modules/.
    at /Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/Compilation.js:2016:28
    at /Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/NormalModuleFactory.js:798:13
    at eval (eval at create (/Users/anu/Desktop/projects/pax-ui/client/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:10:1)
    at /Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/NormalModuleFactory.js:270:22
    at eval (eval at create (/Users/anu/Desktop/projects/pax-ui/client/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:9:1)
    at /Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/NormalModuleFactory.js:434:22
    at /Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/NormalModuleFactory.js:116:11
    at /Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/NormalModuleFactory.js:670:25
    at /Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/NormalModuleFactory.js:855:8
    at /Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/NormalModuleFactory.js:975:5
ModuleNotFoundError: Module not found: Error: You attempted to import /Users/anu/Desktop/projects/pax-ui/client/node_modules/@storybook/preset-create-react-app/node_modules/@pmmmwh/react-refresh-webpack-plugin/overlay/index.js which falls outside of the project src/ directory. Relative imports outside of src/ are not supported.
You can either move it inside src/, or add a symlink to it from project's node_modules/.
    at /Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/Compilation.js:2016:28
    at /Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/NormalModuleFactory.js:798:13
    at eval (eval at create (/Users/anu/Desktop/projects/pax-ui/client/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:10:1)
    at /Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/NormalModuleFactory.js:270:22
    at eval (eval at create (/Users/anu/Desktop/projects/pax-ui/client/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:9:1)
    at /Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/NormalModuleFactory.js:434:22
    at /Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/NormalModuleFactory.js:116:11
    at /Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/NormalModuleFactory.js:670:25
    at /Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/NormalModuleFactory.js:855:8
    at /Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/NormalModuleFactory.js:975:5
ModuleNotFoundError: Module not found: Error: You attempted to import /Users/anu/Desktop/projects/pax-ui/client/node_modules/@storybook/preset-create-react-app/node_modules/@pmmmwh/react-refresh-webpack-plugin/lib/runtime/RefreshUtils.js which falls outside of the project src/ directory. Relative imports outside of src/ are not supported.
You can either move it inside src/, or add a symlink to it from project's node_modules/.
    at /Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/Compilation.js:2016:28
    at /Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/NormalModuleFactory.js:798:13
    at eval (eval at create (/Users/anu/Desktop/projects/pax-ui/client/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:10:1)
    at /Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/NormalModuleFactory.js:270:22
    at eval (eval at create (/Users/anu/Desktop/projects/pax-ui/client/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:9:1)
    at /Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/NormalModuleFactory.js:434:22
    at /Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/NormalModuleFactory.js:116:11
    at /Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/NormalModuleFactory.js:670:25
    at /Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/NormalModuleFactory.js:855:8
    at /Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/NormalModuleFactory.js:975:5
ModuleNotFoundError: Module not found: Error: You attempted to import /Users/anu/Desktop/projects/pax-ui/client/node_modules/@storybook/preset-create-react-app/node_modules/@pmmmwh/react-refresh-webpack-plugin/overlay/index.js which falls outside of the project src/ directory. Relative imports outside of src/ are not supported.
You can either move it inside src/, or add a symlink to it from project's node_modules/.
    at /Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/Compilation.js:2016:28
    at /Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/NormalModuleFactory.js:798:13
    at eval (eval at create (/Users/anu/Desktop/projects/pax-ui/client/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:10:1)
    at /Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/NormalModuleFactory.js:270:22
    at eval (eval at create (/Users/anu/Desktop/projects/pax-ui/client/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:9:1)
    at /Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/NormalModuleFactory.js:434:22
    at /Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/NormalModuleFactory.js:116:11
    at /Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/NormalModuleFactory.js:670:25
    at /Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/NormalModuleFactory.js:855:8
    at /Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/NormalModuleFactory.js:975:5
CodeGenerationError: Cannot read properties of undefined (reading 'module')
    at /Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/Compilation.js:3339:18
    at /Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/Cache.js:91:34
    at Array.<anonymous> (/Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/cache/MemoryCachePlugin.js:45:13)
    at /Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/Cache.js:91:19
    at Hook.eval [as callAsync] (eval at create (/Users/anu/Desktop/projects/pax-ui/client/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:19:1)
    at Cache.get (/Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/Cache.js:75:18)
    at ItemCacheFacade.get (/Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/CacheFacade.js:111:15)
    at Compilation._codeGenerationModule (/Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/Compilation.js:3322:9)
    at /Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/Compilation.js:3229:11
    at arrayIterator (/Users/anu/Desktop/projects/pax-ui/client/node_modules/neo-async/async.js:3467:9)
TypeError: Cannot read properties of undefined (reading 'module')
    at ProvidedDependencyTemplate.apply (/Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/dependencies/ProvidedDependency.js:122:61)
    at JavascriptGenerator.sourceDependency (/Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/javascript/JavascriptGenerator.js:206:12)
    at JavascriptGenerator.sourceModule (/Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/javascript/JavascriptGenerator.js:112:9)
    at JavascriptGenerator.generate (/Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/javascript/JavascriptGenerator.js:98:8)
    at NormalModule.codeGeneration (/Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/NormalModule.js:1204:22)
    at /Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/Compilation.js:3329:22
    at /Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/Cache.js:91:34
    at Array.<anonymous> (/Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/cache/MemoryCachePlugin.js:45:13)
    at /Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/Cache.js:91:19
    at Hook.eval [as callAsync] (eval at create (/Users/anu/Desktop/projects/pax-ui/client/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:19:1)
CodeGenerationError: Cannot read properties of undefined (reading 'module')
    at /Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/Compilation.js:3339:18
    at /Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/Cache.js:91:34
    at Array.<anonymous> (/Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/cache/MemoryCachePlugin.js:45:13)
    at /Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/Cache.js:91:19
    at Hook.eval [as callAsync] (eval at create (/Users/anu/Desktop/projects/pax-ui/client/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:19:1)
    at Cache.get (/Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/Cache.js:75:18)
    at ItemCacheFacade.get (/Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/CacheFacade.js:111:15)
    at Compilation._codeGenerationModule (/Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/Compilation.js:3322:9)
    at /Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/Compilation.js:3229:11
    at arrayIterator (/Users/anu/Desktop/projects/pax-ui/client/node_modules/neo-async/async.js:3467:9)
TypeError: Cannot read properties of undefined (reading 'module')
    at ProvidedDependencyTemplate.apply (/Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/dependencies/ProvidedDependency.js:122:61)
    at JavascriptGenerator.sourceDependency (/Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/javascript/JavascriptGenerator.js:206:12)
    at JavascriptGenerator.sourceModule (/Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/javascript/JavascriptGenerator.js:112:9)
    at JavascriptGenerator.generate (/Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/javascript/JavascriptGenerator.js:98:8)
    at NormalModule.codeGeneration (/Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/NormalModule.js:1204:22)
    at /Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/Compilation.js:3329:22
    at /Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/Cache.js:91:34
    at Array.<anonymous> (/Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/cache/MemoryCachePlugin.js:45:13)
    at /Users/anu/Desktop/projects/pax-ui/client/node_modules/webpack/lib/Cache.js:91:19
    at Hook.eval [as callAsync] (eval at create (/Users/anu/Desktop/projects/pax-ui/client/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:19:1)

WARN Broken build, fix the error above.
WARN You may need to refresh the browser.`

PACKAGE VERSION

"devDependencies": {
    "@storybook/addon-actions": "^6.5.13",
    "@storybook/addon-essentials": "^6.5.13",
    "@storybook/addon-interactions": "^6.5.13",
    "@storybook/addon-links": "^6.5.13",
    "@storybook/builder-webpack4": "^6.5.13",
    "@storybook/builder-webpack5": "^6.5.13",
    "@storybook/manager-webpack4": "^6.5.13",
    "@storybook/manager-webpack5": "^6.5.13",
    "@storybook/node-logger": "^6.5.13",
    "@storybook/preset-create-react-app": "^3.2.0",
    "@storybook/react": "^6.5.13",
    "react-scripts": "^5.0.1",
    "webpack": "^5.75.0"
  },

To Reproduce

No response

System

Mac OS 13.0 (22A380)
Node 16/18

Additional context

No response

wztech0192 commented 1 year ago

I had the same issue, but update @storybook/preset-create-react-app to the latest version ^4.1.2 fixed it.

"@storybook/preset-create-react-app": "^4.1.2",