Pm2: I can't install pm2-logrotate for Windows

Created on 8 Feb 2018  路  11Comments  路  Source: Unitech/pm2

I tried install pm2-logrotate, but error was detected.

C:UsersAdministratorAppDataRoamingnpmnode_modulespm2libAPIModulesModularizer.js:148
process.chdir(process.env.HOME);
^

TypeError: Bad argument.
at C:UsersAdministratorAppDataRoamingnpmnode_modulespm2libAPIModulesModularizer.js:148:13
at C:UsersAdministratorAppDataRoamingnpmnode_modulespm2node_modulesmkdirpindex.js:48:26
at FSReqWrap.oncomplete (fs.js:153:5)

Please tell me the solution.

Versions.
pm2 2.9.3
npm 5.5.1
node 8.9.3
Windows Server 2016 Standard

Pending Release Windows Bug

Most helpful comment

When can we expect this to be released? I am still facing this issue in 2.10.3 version.

All 11 comments

hi @moto-a,

Could you put here what you have in variable : process.env.HOME ?
process.chdir can only fail if directory doesn't exist or if you don't have rights on it.

Thank you for your reply.

process.env.HOME is undefined.
I do not know why it is undefined.

And if you force a value to your HOME variable does it work ?
It's probably an edge case.

@wallet77 Not an edge case, the value of HOME is never set under windows, it's HOME_DIR from memory and also i don't see the point to chdir in this code.

chdir is the function which throw an error because HOME variable is empty.
For windows it's USERPROFILE variable.

The best (generic) way to achieve this is to use require('os').homedir().

When can we expect this to be released? I am still facing this issue in 2.10.3 version.

@preraksola
Thanks @wallet77, i may find a solution.

set HOME=%USERPROFILE%
pm2 install pm2-logrotate

Hi @preraksola

I will be released with 3.0.0 version. But I don't know when exactly. I hope in a few weeks.

set HOME=%USERPROFILE%
pm2 install pm2-logrotate

Awesome!!
Thanks to you, this problem has been solved.

There seems to be further issues when HOME has a space in it, at least on Windows. At some point in the process, PM2 tries to operate on only the part of the dir before the first space.

For example, having this be your HOME would fail:

C:\Users\Test User

PM2 3.0.0 has been released:

$ npm install pm2@latest -g
$ pm2 update

Be aware of breaking changes, especially drop support for node 0.12.
Full list here : https://github.com/Unitech/pm2/blob/master/CHANGELOG.md

Was this page helpful?
0 / 5 - 0 ratings

Related issues

phra picture phra  路  3Comments

psparago picture psparago  路  3Comments

shaunwarman picture shaunwarman  路  3Comments

rangercyh picture rangercyh  路  4Comments

FujiHaruka picture FujiHaruka  路  3Comments