daemon.node icon indicating copy to clipboard operation
daemon.node copied to clipboard

TypeError: "cwd" must be a string on Node 8

Open zipang opened this issue 7 years ago • 13 comments

After upgrading to Node 8, we have an error on startup when launching a NodeBB server. This issue has been documented here : https://community.nodebb.org/topic/10765/error-starting-nodebb-after-upgrade

And here is the full error stack which has its origin in the daemon module used by NodeBB :

TypeError: "cwd" must be a string
    at normalizeSpawnArguments (child_process.js:380:11)
    at Object.exports.spawn (child_process.js:465:38)
    at Function.module.exports.daemon (/www/node-bb/node_modules/daemon/index.js:50:31)
    at module.exports (/www/node-bb/node_modules/daemon/index.js:25:20)
    at /www/node-bb/loader.js:223:21
    at FSReqWrap.oncomplete (fs.js:135:15)

According to the API documentation, process.cwd() is effectively a method : https://nodejs.org/api/process.html#process_process_cwd

The fix is quite trivial and i will provide a Pull Request for it.

zipang avatar Jun 06 '17 12:06 zipang

Is there anyone who could review my PR ? It should be really fast i believe.

zipang avatar Jun 14 '17 13:06 zipang

For anyone else affected, a quick workaround is to apply zipang's PR:

npm install 'github:zipang/daemon.node#48d0977c26fb3a6a44ae99aae3471b9d5a761085'

unilynx avatar Jun 22 '17 11:06 unilynx

Paging @indexzero, is it possible for you to merge this PR? It's a trivial bug fix, and would help us out. Node 8 is now in LTS, so many more people will be using this. Two character fix:

https://github.com/zipang/daemon.node/commit/48d0977c26fb3a6a44ae99aae3471b9d5a761085

Before:

var cwd = opt.cwd || process.cwd;

After:

var cwd = opt.cwd || process.cwd();

Thanks!

jhuckaby avatar Nov 10 '17 03:11 jhuckaby

@indexzero Ping, can we get #42 into an NPM release?

p-salido avatar Nov 14 '17 17:11 p-salido

The workaround for this issue should be to pass in cwd in options, which typically would be set to /.

p-salido avatar Nov 14 '17 17:11 p-salido

same issue here but when implemented in modern node way it works

c1tt1 avatar Dec 14 '17 00:12 c1tt1

@stern0 What is the "modern node way"?

jhuckaby avatar Dec 14 '17 00:12 jhuckaby

@jhuckaby actually I was wrong the same issue persists

c1tt1 avatar Dec 14 '17 00:12 c1tt1

@jhuckaby but the latest PR works

c1tt1 avatar Dec 14 '17 00:12 c1tt1

@stern0 Yup, just need OP to merge it ;)

jhuckaby avatar Dec 14 '17 01:12 jhuckaby

As this module appears abandoned, I went ahead and created the daemonize-process module, in case anyone's interested in a maintained version of daemon.

silverwind avatar Jan 05 '18 22:01 silverwind

Thank you @silverwind. You saved my life. If you don't did it, I'll fork daemon project to fix this issue. Congratulations

rafaelquines avatar Feb 03 '18 00:02 rafaelquines

Using daemonize-process solved it.

FredericGuilbault avatar Oct 20 '18 17:10 FredericGuilbault