New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error when run npm start: Class constructor ServeCommand cannot be invoked without 'new' #2272
Comments
Please update all deps (check global too), we don't have |
You should update |
Thanks @alexander-akait. When I tried 4.3.0 I got this issue:
Please, advice. Thanks. |
Change:
Syntax - |
But, yes we need fix it |
What are the steps to reproduce this behavior? |
Original issue should be fixed by updating webpack-cli to latest version, #2272 (comment) require more complex logic for parsing args |
Thanks a lot, @alexander-akait . It works with 4.3.1 with corrected command line. |
After long attempts to allow
Also we load commands lazy to reduce memory and improve performance, so we cannot analyze args to get command. Yep, it works in some version, but only because we have bugs in parsing. So, here two issues:
I am sorry that some developers have the problem, hope I describe everything above, anyway feel free to feedback |
I have the latest version with webpack 4 and I have the same error. I can bundle the app with no problem with "devDependencies": {
"@webpack-cli/serve": "^1.2.2",
"autoprefixer": "^7.1.2",
"babel-core": "^6.22.1",
"babel-eslint": "^8.2.6",
"babel-helper-vue-jsx-merge-props": "^2.0.3",
"babel-loader": "^7.1.1",
"babel-plugin-istanbul": "^4.1.1",
"babel-plugin-syntax-jsx": "^6.18.0",
"babel-plugin-transform-runtime": "^6.22.0",
"babel-plugin-transform-vue-jsx": "^3.5.0",
"babel-preset-env": "^1.3.2",
"babel-preset-stage-2": "^6.22.0",
"babel-register": "^6.22.0",
"chai": "^4.1.2",
"chalk": "^2.0.1",
"chromedriver": "^83.0.1",
"copy-webpack-plugin": "^4.0.1",
"cross-env": "^5.0.1",
"cross-spawn": "^5.0.1",
"css-loader": "^0.28.11",
"dotenv-webpack": "^6.0.0",
"eslint": "^7.18.0",
"eslint-config-prettier": "^6.15.0",
"eslint-config-standard": "^10.2.1",
"eslint-friendly-formatter": "^3.0.0",
"eslint-loader": "^1.9.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-node": "^5.2.0",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-promise": "^3.4.0",
"eslint-plugin-standard": "^3.0.1",
"eslint-plugin-vue": "^4.7.1",
"eslint-webpack-plugin": "^2.4.3",
"extract-text-webpack-plugin": "^3.0.0",
"file-loader": "^1.1.4",
"friendly-errors-webpack-plugin": "^1.6.1",
"html-webpack-plugin": "^4.5.1",
"inject-loader": "^3.0.0",
"karma": "^1.4.1",
"karma-coverage": "^1.1.1",
"karma-mocha": "^1.3.0",
"karma-phantomjs-launcher": "^1.0.2",
"karma-phantomjs-shim": "^1.4.0",
"karma-sinon-chai": "^1.3.1",
"karma-sourcemap-loader": "^0.3.8",
"karma-spec-reporter": "0.0.31",
"karma-webpack": "^2.0.2",
"miragejs": "^0.1.41",
"mocha": "^3.2.0",
"nightwatch": "^1.5.1",
"node-notifier": "^5.1.2",
"node-sass": "^4.14.1",
"optimize-css-assets-webpack-plugin": "^3.2.0",
"ora": "^1.2.0",
"phantomjs-prebuilt": "^2.1.14",
"portfinder": "^1.0.28",
"postcss-import": "^11.0.0",
"postcss-loader": "^2.0.8",
"postcss-url": "^7.2.1",
"prettier": "^2.2.1",
"rimraf": "^2.6.0",
"sass-loader": "^8.0.2",
"selenium-server": "^3.0.1",
"semver": "^5.3.0",
"shelljs": "^0.7.6",
"sinon": "^4.0.0",
"sinon-chai": "^2.8.0",
"style-loader": "^2.0.0",
"terser-webpack-plugin": "^4.2.3",
"uglifyjs-webpack-plugin": "^1.1.1",
"url-loader": "^0.5.8",
"vue-loader": "^15.9.6",
"vue-style-loader": "^3.0.1",
"vue-template-compiler": "^2.6.12",
"webpack": "^4.44.2",
"webpack-bundle-analyzer": "^4.4.0",
"webpack-merge": "^4.1.0"
},
|
Update your deps |
Is there a way to fix this when you have Webpack pinned at |
For me it worked by deleting the node modules and reinstall it |
Tried this, got the following error: |
This worked for me for now; Changing the webpack-dev-server version in the package.json file to:
And then run Source: https://stackoverflow.com/a/69050300/2774342 P.S. This will be likely a temporary solution, while a new version is released, so for future reference (some months from now I guess) this answer will be deprecated. |
This is showing for me with webpack "^4.46.0" |
this error is happening for me with webpack-cli ^4.9.1 clearing my node_modules and reinstalling did seem to resolve it, leaving me with my next error to iron out :) |
it's also useful for me (TypeError: Class constructor ServeCommand cannot be invoked without 'new' |
(node:50249) UnhandledPromiseRejectionWarning: TypeError: Class constructor ServeCommand cannot be invoked without 'new'
at run (/Users/sonlam/workspaces/octupi/raindrop/node_modules/webpack-cli/lib/utils/resolve-command.js:33:12)
at Command. (/Users/sonlam/workspaces/octupi/raindrop/node_modules/webpack-cli/lib/utils/arg-parser.js:34:58)
at Command.listener [as _actionHandler] (/Users/sonlam/workspaces/octupi/raindrop/node_modules/webpack-cli/node_modules/commander/index.js:426:31)
at Command._parseCommand (/Users/sonlam/workspaces/octupi/raindrop/node_modules/webpack-cli/node_modules/commander/index.js:1002:14)
at Command._dispatchSubcommand (/Users/sonlam/workspaces/octupi/raindrop/node_modules/webpack-cli/node_modules/commander/index.js:953:18)
at Command._parseCommand (/Users/sonlam/workspaces/octupi/raindrop/node_modules/webpack-cli/node_modules/commander/index.js:970:12)
at Command.parse (/Users/sonlam/workspaces/octupi/raindrop/node_modules/webpack-cli/node_modules/commander/index.js:801:10)
at argParser (/Users/sonlam/workspaces/octupi/raindrop/node_modules/webpack-cli/lib/utils/arg-parser.js:164:27)
at runCLI (/Users/sonlam/workspaces/octupi/raindrop/node_modules/webpack-cli/lib/bootstrap.js:11:24)
at Object. (/Users/sonlam/workspaces/octupi/raindrop/node_modules/webpack-cli/bin/cli.js:24:5)
(Use
node --trace-warnings ...
to show where the warning was created)What is the current behavior?
package.json:
Steps to reproduce the behavior:
Expected behavior
Screenshots
Please paste the results of
webpack-cli info
here, and mention other relevant informationnodejs: v 15.3.0
The text was updated successfully, but these errors were encountered: