-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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 in file semver/semver.js:239:14 #1094
Comments
Is there an easy way for me to reproduce? Can you print the output of Is there a reason you have node-gyp in your node_modules directory instead of using the one that is bundled with node/npm? |
I'm encountering the same issue, and have come across this before. Last time I found that removing a particular package, which didn't require node-gyp compilation, fixed it for some reason. I had to find this package by trial and error, which takes a while with a large application.
Adding the I'm using electron-builder, which is calling node-gyp, so for me the error may be coming from there - but it might be worth adding some kind of check that gives a nicer error message when this happens. |
The newer versions of semver include the undefined check by default. I think the behavior I was encountering was down to the way npm resolves modules. If I included a module that had an earlier version of semver as a dependency, node would use that version instead (as node-gyp is happy with semver versions from 2 to 5) which caused the error to occur. The simple fix is to explicitly require semver 5 which will override anything else.
For reproducing the issue, try passing |
I think we can upgrade to a newer semver in node-gyp. We specified a broad range so we could share it with npm but since npm upgraded their dependency recently, we can too now. |
when I run it - parameter "version" === undefined
For fix it I just add code above into function
function parse(version, loose) {
The text was updated successfully, but these errors were encountered: