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

fails on Windows due to process.env.HOME being undefined #91

Closed
jamesmanning opened this issue Jun 4, 2016 · 3 comments
Closed

fails on Windows due to process.env.HOME being undefined #91

jamesmanning opened this issue Jun 4, 2016 · 3 comments

Comments

@jamesmanning
Copy link

jamesmanning commented Jun 4, 2016

Currently running 'yo typings foo' on a Windows machine fails unless you specifically set the HOME environment variable

» yo typings npm-node-json-db
path.js:7
throw new TypeError('Path must be a string. Received ' + inspect(path));
^

TypeError: Path must be a string. Received undefined
at assertPath (path.js:7:11)
at Object.join (path.js:466:7)
at Object. (C:\Users\james\AppData\Roaming\npm\node_modules\generator-typings\generators\app\createTemplateCommands.js:9:31)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)

Appears to be used in 2 places AFAICT

https://github.com/typings/generator-typings/blob/e412656ae9e847a6570564988c191d5a5d13bf26/generators/app/index.js#L19

https://github.com/typings/generator-typings/blob/e412656ae9e847a6570564988c191d5a5d13bf26/generators/app/createTemplateCommands.js#L9

AFAIK Node v4 is when the os.homedir() was added which you could use instead of you're already requiring (are you're ok requiring) v4 or later.

https://nodejs.org/api/os.html#os_os_homedir

Otherwise, you can use the os-homedir npm module as a polyfill, or even just use a simple function to check for win32 like in this SO answer

function getUserHome() {
  return process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME'];
}
@unional
Copy link
Collaborator

unional commented Jun 4, 2016

Thanks for the excellent report! Will fix it this afternoon

@jamesmanning
Copy link
Author

@unional wow, that was a crazy fast response! Thanks!!

@unional
Copy link
Collaborator

unional commented Jun 5, 2016

I have released 1.0.1 for this. Please see if it solves the problem.

I'm in the process of setting up appveyor, hopefully will avoid windows platform issue in the future. :)

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

No branches or pull requests

2 participants