-
Notifications
You must be signed in to change notification settings - Fork 17
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 checking NODE_PATH #50
Comments
Can you create the PR? Line 51 in df93f8a
What os are you running? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Today I installed yeoman and yeoman doctor flagged an issue with "NODE_PATH matches the npm root".
In this Google did not appear to be my friend so I started investigating myself.
I found yeoman-doctor/lib/rules/node-path.js and started debugging the old way by adding
console.log
lines. In the exported functionverify
I added aconsole.log
for the error in the catch. The error message read "TypeError: filepath.trim is not a function".In the complete script file there is only one line with a trim function and that is in the function fixPath. That function is being called on 2 places, for each of the paths in the NODE_PATH environment value and once for the output of the command
npm -g root --silent
so I added a console.log line to thefixPath
function to see the incoming value of filepath. The output ofnpm -g root --silent
appeared to contain a new line character all the rest looked normal so I suspected that new line to be the culprit. So I tried to replace it withfilepath.replace(/^\n|\n$/g, '')
but it only made the error being thrown by the replace function instead. At this point I wondered how this could be, a quick Google and the wisdom of "don't trust your input" got me the idea of addingtoString()
to thefilepath
variable before the trim function. That did the trick, the error went away and "NODE_PATH matches the npm root" was being flagged as okay.I could create a pull request for my fix but first I want to make sure if I'm not missing anything obvious.
The text was updated successfully, but these errors were encountered: