Skip to content
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

windows 8 error: path.js:204 throw new TypeError('Arguments to path.join must be strings'); #300

Closed
devdude13 opened this issue Jun 20, 2013 · 8 comments · Fixed by #334
Closed

Comments

@devdude13
Copy link

Found this on js-beautify 1.4

Root cause: in js-beautify\js\lib\cli.js:135:22 process.env.HOME is undefined

Work around is to define the environment variable like so in powershell before invoking js-beautify
$env:HOME="c:\users\johndoe"

Note: I am operating under all defaults. I haven't customized the install in any way and it looks like js-beautify expects an environment variable HOME to be defined which is (sometimes) not the case

Full error

PS C:\Users\johndoe\code\html\bootstrapPlayground> js-beautify --file "C:\Users\johndoe\code\html\test.html"

path.js:204
throw new TypeError('Arguments to path.join must be strings');
^
TypeError: Arguments to path.join must be strings
at f (path.js:204:15)
at Object.filter (native)
at Object.exports.join (path.js:209:40)
at Object.exports.interpret (C:\Users\johndoe\AppData\Roaming\npm\node_modules\js-beautify\js\lib\cli.js:135:22)
at Object. (C:\Users\johndoe\AppData\Roaming\npm\node_modules\js-beautify\js\bin\js-beautify.js:4:5)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)

@bitwiseman
Copy link
Member

Perfect bug report, thanks!

We don't cover windows specifically in our test matrix, so understandable.

@fprijate
Copy link

fprijate commented Jul 6, 2013

Hi

The reason is that cl.js uses HOME environment variable.

Solutions:

  1. run it in MSYS console.

or

2 SET HOME=XX

or preferably

3 change line 135 in cl.js to
cc.find(path.join(process.env.HOME || '"", ".jsbeautifyrc")),

regards
Franček

@evocateur
Copy link
Contributor

Seems like we should be using process.env.USERPROFILE instead of the empty string, as indicated in this stack overflow answer. With the empty string alternate, on Windows the search for .jsbeautifyrc in the current directory will happen twice.

@fprijate
Copy link

fprijate commented Jul 7, 2013

Yes, it's better solution.
Code should be:
cc.find(path.join(process.env.HOME || process.env.USERPROFILE || '"", ".jsbeautifyrc")),
Anyhow || "" must be in expression, because there is possibility that both $HOME and $USERPROFILE
are not defined.

regards

@fprijate
Copy link

fprijate commented Jul 7, 2013

One solution is to set default $HOME for every
process.platform

@bitwiseman
Copy link
Member

It looks like this was at least partially addressed by #304, yes?

@evocateur
Copy link
Contributor

It is mitigated, yes, but the actual functionality provided by that line will be lost to Windows users (utilizing a config file in the user's home directory).

@einars
Copy link
Contributor

einars commented Jul 8, 2013

So, a pull request from somebody with a windows box who can add the userprofile check and verify that rc in homedir is working, is welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants