-
-
Notifications
You must be signed in to change notification settings - Fork 612
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
TypeError: Cannot read property 'length' of undefined #1023
Comments
Hi, thanks for submitting an issue. It's a bug, I've done a patch here: Which hopefully will land as a patch soon |
@evenstensberg It seems that there is still this bug |
Could you try out the #1024 branch and check if it fixes the bug? |
I ran into this issue and pulled your branch it seems to be working now. |
@evenstensberg not sure if this is to be expected but an empty webpack config object |
actually it might be something else, not quite sure, but trying to plug in my existing config I have seen this error pop up. |
yes, options might be null / undefined, so the error is from validating the schema. Do you think you can figure out when the options obj is nil @ryanspice ? |
@evenstensberg yeah it seems like validateschemea.js on [email protected] doesnt have a return |
@sokra can we have that? |
I created a bug report: webpack/webpack#9591 I was gonna create a branch and make a PR but then I realised I dont think i can do that there. |
The |
Do you have a proposed way of using the schema with the new api? Not getting a message from validating the schema as of: const validateSchema = require("webpack").validateSchema;
const ValidationError = require("webpack").validate;
const webpackConfigurationValidationErrors = validateSchema(webpackConfigurationSchema, options);
if (webpackConfigurationValidationErrors.length) {
const error = ValidationError(webpackConfigurationValidationErrors);
console.error(error.message);
process.exit(-1);
} |
try {
validateSchema(webpackConfigurationSchema, options);
} catch(error) {
console.error(error.message);
process.exit(-1);
} |
If you want to support both version maybe like this: let error;
try {
const errors = validateSchema(webpackConfigurationSchema, options);
if(errors && errors.length > 0) {
const WebpackOptionsValidationError = require("webpack").WebpackOptionsValidationError;
error = new WebpackOptionsValidationError(errors);
}
} catch(err) {
error = err;
}
if(error) {
console.error(error.message);
process.exit(-1);
} |
I'm not quite sure I understand why returning the value isn't appropriate.. It returns an empty array with no errors, would it not have an array populated with errors if there were some? |
@sokra @evenstensberg no? lol |
Fixed by #1065. Landed in v3.3.8. |
Describe the bug
A 💯 way to do this is to provide your configuration via a GitHub gist and/or to use markdown when describing which commands you used when the error occurred! Be precise and clear in your description of the bug.
What is the current behavior?
when I run
webpack --mode development(or production)
, the webpack-cli showsTypeError: Cannot read property 'length' of undefined
on the linenode_modules\webpack-cli\bin\cli.js:93
. my computer is win10This is where you elaborate on the current behavior of the cli, how it behaves normally differing from the previous version/build you did.
To Reproduce
Steps to reproduce the behavior:
1.just create a folder on win10
2.npm i -S webpack@next
3.npm i -S webpack-cli@latest
4.write "dev": "webpack --mode development" in package.json
5.npm run dev
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Please paste the results of
webpack-cli info
here, and mention other relevant informationAdditional context
Add any other context about the problem here like linking to an similar issue you might think is the cause.
The text was updated successfully, but these errors were encountered: