nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.65k stars 2.36k forks source link

Fresh setup `build-storybook` shows error "Cannot find module '@nrwl/webpack/src/utils/config'" #14455

Closed mauris closed 1 year ago

mauris commented 1 year ago

Current Behavior

After running npx nx run <libName>:build-storybook, I got the following error output:


>  NX  Storybook builder starting ...

info => Cleaning outputDir: /Users/mauris/work/test/dist/storybook/mode
info => Loading presets
WARN   Failed to load preset: {"type":"presets","name":"/Users/mauris/work/test/node_modules/@nrwl/react/plugins/storybook/index.js"} on level 1
ERR! Error: Cannot find module '@nrwl/webpack/src/utils/config'
ERR! Require stack:
ERR! - /Users/mauris/work/test/node_modules/@nrwl/react/plugins/storybook/index.js
ERR! - /Users/mauris/work/test/node_modules/@storybook/core-common/dist/cjs/presets.js
ERR! - /Users/mauris/work/test/node_modules/@storybook/core-common/dist/cjs/index.js
ERR! - /Users/mauris/work/test/node_modules/@storybook/core-server/dist/cjs/index.js
ERR! - /Users/mauris/work/test/node_modules/@nrwl/storybook/src/executors/build-storybook/build-storybook.impl.js
ERR! - /Users/mauris/work/test/node_modules/nx/src/config/workspaces.js
ERR! - /Users/mauris/work/test/node_modules/nx/src/command-line/run.js
ERR! - /Users/mauris/work/test/node_modules/nx/bin/run-executor.js
ERR!     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
ERR!     at Function.Module._load (internal/modules/cjs/loader.js:746:27)
ERR!     at Module.require (internal/modules/cjs/loader.js:974:19)
ERR!     at require (internal/modules/cjs/helpers.js:101:18)
ERR!     at Object.<anonymous> (/Users/mauris/work/test/node_modules/@nrwl/react/plugins/storybook/index.js:6:18)
ERR!     at Module._compile (internal/modules/cjs/loader.js:1085:14)
ERR!     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
ERR!     at Module.load (internal/modules/cjs/loader.js:950:32)
ERR!     at Function.Module._load (internal/modules/cjs/loader.js:790:12)
ERR!     at Module.require (internal/modules/cjs/loader.js:974:19)
ERR!  Error: Cannot find module '@nrwl/webpack/src/utils/config'
ERR! Require stack:
ERR! - /Users/mauris/work/test/node_modules/@nrwl/react/plugins/storybook/index.js
ERR! - /Users/mauris/work/test/node_modules/@storybook/core-common/dist/cjs/presets.js
ERR! - /Users/mauris/work/test/node_modules/@storybook/core-common/dist/cjs/index.js
ERR! - /Users/mauris/work/test/node_modules/@storybook/core-server/dist/cjs/index.js
ERR! - /Users/mauris/work/test/node_modules/@nrwl/storybook/src/executors/build-storybook/build-storybook.impl.js
ERR! - /Users/mauris/work/test/node_modules/nx/src/config/workspaces.js
ERR! - /Users/mauris/work/test/node_modules/nx/src/command-line/run.js
ERR! - /Users/mauris/work/test/node_modules/nx/bin/run-executor.js
ERR!     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
ERR!     at Function.Module._load (internal/modules/cjs/loader.js:746:27)
ERR!     at Module.require (internal/modules/cjs/loader.js:974:19)
ERR!     at require (internal/modules/cjs/helpers.js:101:18)
ERR!     at Object.<anonymous> (/Users/mauris/work/test/node_modules/@nrwl/react/plugins/storybook/index.js:6:18)
ERR!     at Module._compile (internal/modules/cjs/loader.js:1085:14)
ERR!     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
ERR!     at Module.load (internal/modules/cjs/loader.js:950:32)
ERR!     at Function.Module._load (internal/modules/cjs/loader.js:790:12)
ERR!     at Module.require (internal/modules/cjs/loader.js:974:19) {
ERR!   code: 'MODULE_NOT_FOUND',
ERR!   requireStack: [
ERR!     '/Users/mauris/work/test/node_modules/@nrwl/react/plugins/storybook/index.js',
ERR!     '/Users/mauris/work/test/node_modules/@storybook/core-common/dist/cjs/presets.js',
ERR!     '/Users/mauris/work/test/node_modules/@storybook/core-common/dist/cjs/index.js',
ERR!     '/Users/mauris/work/test/node_modules/@storybook/core-server/dist/cjs/index.js',
ERR!     '/Users/mauris/work/test/node_modules/@nrwl/storybook/src/executors/build-storybook/build-storybook.impl.js',
ERR!     '/Users/mauris/work/test/node_modules/nx/src/config/workspaces.js',
ERR!     '/Users/mauris/work/test/node_modules/nx/src/command-line/run.js',
ERR!     '/Users/mauris/work/test/node_modules/nx/bin/run-executor.js'
ERR!   ]
ERR! }

Expected Behavior

No error should be shown

Github Repo

No response

Steps to Reproduce

  1. Run npx nx run <libName>:build-storybook on a newly setup workspace.

Nx Report

>  NX   Report complete - copy this into the issue template

   Node : 14.21.2
   OS   : darwin arm64
   npm  : 6.14.17

   nx : 15.5.2
   @nrwl/angular : Not Found
   @nrwl/cypress : 15.5.2
   @nrwl/detox : Not Found
   @nrwl/devkit : 15.5.2
   @nrwl/esbuild : Not Found
   @nrwl/eslint-plugin-nx : 15.5.2
   @nrwl/expo : Not Found
   @nrwl/express : Not Found
   @nrwl/jest : 15.5.2
   @nrwl/js : 15.5.2
   @nrwl/linter : 15.5.2
   @nrwl/nest : Not Found
   @nrwl/next : Not Found
   @nrwl/node : Not Found
   @nrwl/nx-cloud : Not Found
   @nrwl/nx-plugin : Not Found
   @nrwl/react : 15.5.2
   @nrwl/react-native : Not Found
   @nrwl/rollup : 15.5.2
   @nrwl/schematics : Not Found
   @nrwl/storybook : 15.5.2
   @nrwl/web : 15.5.2
   @nrwl/webpack : Not Found
   @nrwl/workspace : 15.5.2
   @nrwl/vite : Not Found
   typescript : 4.8.4
   ---------------------------------------
   Local workspace plugins:
   ---------------------------------------
   Community plugins:

Failure Logs

No response

Additional Information

No response

alexmbp commented 1 year ago

I have the same issue in the repo. But my setup was working before I updated Nx. Issue appeared after I migrated from 15.4.1 to 15.5.2.

I was able to get rid of the warning, by manually installing @nrwl/webpack.

mauris commented 1 year ago

I upgraded from 15.4.4. It started showing when I was at 15.4.8. I had the same resolution to rid the errors, by installing @nrwl/webpack. 🙇🏻

jaysoo commented 1 year ago

Looks like webpack is not installed. We need to add a migration to install it if it's missing.

Previously it must have resolved due to @nrwl/react and @nrwl/web having a dependency on it, and it was hoisted to root node_modules. I'll patch it.

github-actions[bot] commented 1 year ago

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.