webpack-cli: Unable to load '@webpack-cli/serve' command
Describe the bug
RedwoodJS’s dev server uses webpack-dev-server
under the hood. It broke as soon as @webpack-cli/serve
v1.6
was released.
Redwood users start the dev server with yarn rw dev
. It runs this command:
cd "${rwjsPaths.web.base}" && yarn cross-env NODE_ENV=development RWJS_WATCH_NODE_MODULES=${
watchNodeModules ? '1' : ''
} webpack serve --config "${webpackDevConfig}" ${forward}`
Which resolves to something like:
$ /Users/dom/projects/redwood/_sandbox/my-redwood-app/node_modules/.bin/cross-env NODE_ENV=development
RWJS_WATCH_NODE_MODULES= webpack serve --config /Users/dom/projects/redwood/_sandbox/my-redwood-app/node_modules/@redwoodjs/core/config/webpack.development.js
Our webpack development config can be found here; it’s merged with webpack.common.js
, so I’ve included that as well:
- https://github.com/redwoodjs/redwood/blob/main/packages/core/config/webpack.development.js
- https://github.com/redwoodjs/redwood/blob/main/packages/core/config/webpack.common.js
What is the current behavior?
Currently, with the new release of @webpack-cli/serve
, the dev server doesn’t start up and throws:
web | [webpack-cli] Unable to load '@webpack-cli/serve' command
[webpack-cli] TypeError: options.forEach is not a function
To Reproduce
Steps to reproduce the behavior:
- create a
v0.37.2
redwood project usingyarn create redwood-app my-redwood-app
- run
yarn rw dev
- observe the error in the console
All together:
$ yarn create redwood-app my-redwood-app
$ cd my-redwood-app
$ yarn rw dev
$ ...
$ web | [webpack-cli] Unable to load '@webpack-cli/serve' command
[webpack-cli] TypeError: options.forEach is not a function
Expected behavior
The dev server starts up successfully on localhost:8910
.
Screenshots
The dev server broken:
The dev server working:
Please paste the results of npx webpack-cli info
here, and mention other relevant information
System:
OS: macOS 11.1
CPU: (8) x64 Apple M1
Memory: 127.65 MB / 8.00 GB
Binaries:
Node: 14.17.0 - /usr/local/bin/node
Yarn: 1.22.10 - /opt/homebrew/bin/yarn
npm: 7.3.0 - /opt/homebrew/bin/npm
Browsers:
Chrome: 94.0.4606.71
Safari: 14.0.2
Monorepos:
Yarn Workspaces: 1.22.10
Additional context
- Here’s the bug report in redwoodjs/redwood: https://github.com/redwoodjs/redwood/issues/3522
- Here’s our temporary fix: https://github.com/redwoodjs/redwood/pull/3524
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 21
- Comments: 48 (20 by maintainers)
Commits related to this issue
- chore: Update webpack-cli to next minor According to recommendation https://github.com/webpack/webpack-cli/issues/2990#issuecomment-937704258. — committed to vaadin/flow by mshabarov 3 years ago
- chore: Update webpack-cli to next minor (#11996) According to recommendation https://github.com/webpack/webpack-cli/issues/2990#issuecomment-937704258. — committed to vaadin/flow by mshabarov 3 years ago
- Add workaround for https://github.com/webpack/webpack-cli/issues/2990 — committed to model-graph-tools/browser by hpehl 3 years ago
- Update package.json In order to make the app run again, one has to bump "webpack-cli" to 4.9.0. Referencing this issue: https://github.com/webpack/webpack-cli/issues/2990#issuecomment-939925116 — committed to umgefahren/sdk by umgefahren 3 years ago
- Update webpack-cli to 4.9.0 It fixes the "Unable to load '@webpack-cli/serve' command" bug (webpack/webpack-cli#2990) that prevents the dev server from start — committed to FreeFeed/freefeed-react-client by davidmz 3 years ago
- Fix unable to load @webpack-cli/serve command Issue: unable to load @webpack-cli/serve command Resolution: Bump webpack-cli version to v4.9.x Details: https://github.com/webpack/webpack-cli/issues/2... — committed to ministryofjustice/Claim-for-Crown-Court-Defence by naseberry 3 years ago
- Included entire webpack-cli module instead of just webpack-cli/serve in node modules This prevents cross-dependency conflict issue highlighted here: https://github.com/webpack/webpack-cli/issues/2990#... — committed to ministryofjustice/laa-court-data-ui by ivanELEC 3 years ago
- Bump webpack-dev-server from 4.3.1 to 4.4.0 Bumps [webpack-dev-server](https://github.com/webpack/webpack-dev-server) from 4.3.1 to 4.4.0. - [Release notes](https://github.com/webpack/webpack-dev-ser... — committed to ministryofjustice/laa-court-data-ui by dependabot[bot] 3 years ago
- Bump webpack-dev-server from 4.3.1 to 4.4.0 (#759) Bumps [webpack-dev-server](https://github.com/webpack/webpack-dev-server) from 4.3.1 to 4.4.0. - [Release notes](https://github.com/webpack/webpack... — committed to ministryofjustice/laa-court-data-ui by dependabot[bot] 3 years ago
- Remove webpack-cli-serve Update webpack-cli to 4.9.0 There was an regression error in 4.9.0 where including webpack-cli/serve would cause compiling to fail Mentioned here: https://github.com/webpack... — committed to abtion/rails-template by Guldbek 3 years ago
- Remove webpack-cli-serve Update webpack-cli to 4.9.0 There was an regression error in 4.9.0 where including webpack-cli/serve would cause compiling to fail Mentioned here: https://github.com/webpack... — committed to abtion/rails-template by Guldbek 3 years ago
- Remove webpack-cli-serve (#647) Update webpack-cli to 4.9.0 There was an regression error in 4.9.0 where including webpack-cli/serve would cause compiling to fail Mentioned here: https://github... — committed to abtion/rails-template by Guldbek 3 years ago
- Fix webpack dependency https://github.com/webpack/webpack-cli/issues/2990 — committed to tanbt/microfrontend-example by tanbt 3 years ago
- @labkey/build update webpack, npm v8 compatible package-lock.json - Remedy https://github.com/webpack/webpack-cli/issues/2990 which causes `npm run start-link` to fail - Install using `npm install` as... — committed to LabKey/labkey-ui-components by labkey-nicka 3 years ago
- chore(deps): bump webpack-cli to latest It fixes an issue where internal dep was not locked to the correct version in version 4.8.0. See: https://github.com/webpack/webpack-cli/issues/2990 — committed to TankerHQ/quickstart-examples by maximerety 3 years ago
- @labkey/build update webpack, npm v8 compatible package-lock.json - Remedy https://github.com/webpack/webpack-cli/issues/2990 which causes `npm run start-link` to fail - Install using `npm install` as... — committed to LabKey/labkey-ui-components by labkey-nicka 3 years ago
- @labkey/build update webpack, npm v8 compatible package-lock.json - Remedy https://github.com/webpack/webpack-cli/issues/2990 which causes `npm run start-link` to fail - Install using `npm install` as... — committed to LabKey/labkey-ui-components by labkey-nicka 3 years ago
- @labkey/build update webpack, npm v8 compatible package-lock.json - Remedy https://github.com/webpack/webpack-cli/issues/2990 which causes `npm run start-link` to fail - Install using `npm install` as... — committed to LabKey/labkey-ui-components by labkey-nicka 3 years ago
- build(ui): Specify webpack-cli version explicitly because their updates break the build See https://github.com/webpack/webpack-cli/issues/2990 — committed to CLOVIS-AI/Formulaide by CLOVIS-AI 3 years ago
used
4.9.0
instead of4.8.0
fix me the problem…Looks like we have small regression here, but if we revert it, it will create another breaking change, so my recommendation - bump
webpack-cli@4.9.0
and update lock file, also check you don’t have@webpack-cli/serve
inpackage.json
directly.Sorry for this
Yep, because it is internal package you should have webpack-cli
4.9.0
and do not have@webpack-cli/serve
in yourpackage.json
, in lock file it should be1.6.0
FYI, two things you need to do in package.json:
This statement in my
build.gradle.kts
fixes the issue for meSorry for delay, will have time tomorrow, top on my TODO
@Artur-
Can you provide reproducible example? I really can’t reproduce locallyYour problem - lock file was updated i.e. now you have@webpack-cli/serve@1.6.0
, but uses old verison ofwebpack-cli@4.8.0
,@webpack-cli/serve
is internal package and should be updated together withwebpack-cli
I am not using webpack-cli
4.9.0
. I am using webpack-cli4.8.0
I am not sure how this advice helps. My package.json is
and running
yesterday resulted in the dev server starting. Today it results in
it helped me “webpack-cli”: “^4.9.1”,
My fix:
package.json
webpack.config.js - modify devServer settings to:
Thanks, if the minor versions of the packages truly should go hand in hand maybe you can use
~
instead of^
to avoid this in the future and still be able to make internal breaking changes“webpack”: “5.28.0”, “webpack-cli”: “^4.9.1”, “webpack-dev-server”: “3.11.2”
npm --version 6.14.13
node --version v14.17.3
Thank you @alexander-akait Anything @jtoar and I can do to help — please just let us know. We’re open source maintainers as well and don’t take your effort (or webpack-cli) for granted.
I just followed you on Twitter in case DM’s (or to get on a real-time call) would be helpful to you. You can reach me via DM https://twitter.com/thedavidprice
Overall, I think the semver
^
is the reason this is a cascading issue: https://github.com/webpack/webpack-cli/blob/74089ce03c3cb4842d188f0a3a749c2c173ac84e/packages/webpack-cli/package.json#L35imho I’d highly recommend pinning each dependency in that package.json
Thanks, I will looking at this tomorrow (busy right now), maybe do patch release to avoid problem
update your package.json “webpack-cli”: “4.9.0”, “webpack-dev-server”: “^4.4.0”,
@jtoar Here https://github.com/webpack/webpack-cli/issues/2990#issuecomment-937948234 is the same problem as I described above,
webpack-cli
is4.8.0
, but@webpack-cli/serve
is1.6.0
(you need updatewebpack-cli
to4.9.0
version), I can do patch release and release4.8.1
, but it will not help and will not solve the problem, because you pin your dev deps (strongly recommend avoid it, lock files were created to avoid installation new versions on the each installation, but pinning them doesn’t allow developers get fixes, especial security, which released as patch), looks atnode_modules/@redwoodjs/internal/package.json
, and you will see"webpack-cli": "4.8.0",
, to be honestly I don’t understand how I can help to fix problem, yes, we do small breaking change in internal package, sorry for this, but I think will be better to updatewebpack-cli
to the latest stable version, i.e.4.9.0
. Feel free to feedback.And how
@webpack-cli/serve
appears in your deps, we never ask that in our docs…Hi, i get a similar issue when i run browserDevelopmentRun target via gradle, which calls @webpack-cli/serve. I was tinkering around with KotlinJs. Seems, that 1.6.0 broke the build. Until then, everything worked fine for me.
[webpack-cli] Unable to load '@webpack-cli/serve' command [webpack-cli] TypeError: options.forEach is not a function [webpack-cli] TypeError: options.forEach is not a function at WebpackCLI.makeCommand (D:\Workspace\clsky.de\build\js\node_modules\webpack-cli\lib\webpack-cli.js:173:21) at ServeCommand.apply (D:\Workspace\clsky.de\build\js\node_modules\webpack-cli\node_modules\@webpack-cli\serve\lib\index.js:41:19) at loadCommandByName (D:\Workspace\clsky.de\build\js\node_modules\webpack-cli\lib\webpack-cli.js:907:35) at async Command.<anonymous> (D:\Workspace\clsky.de\build\js\node_modules\webpack-cli\lib\webpack-cli.js:1462:17) at async Promise.all (index 0) at async WebpackCLI.run (D:\Workspace\clsky.de\build\js\node_modules\webpack-cli\lib\webpack-cli.js:1500:9) at async runCLI (D:\Workspace\clsky.de\build\js\node_modules\webpack-cli\lib\bootstrap.js:11:9)
I also experienced this issue. Multiple reports from other people with the same error.
Manually pinning (and setting resolution) this package to v1.52.0 is the workaround.