Search code examples
node.jsbashchild-process

Changing directory using NodeJS


Is there a way to change directory using a NodeJS process?

I want something like this:

/$ node_cd /path/to/directory
/path/to/directory$ _

Basically the same effect as 'cd'.

I tried to do it with child_proccess exec but didn't work.


Solution

  • Maybe bash can help?

    Make it a bash alias/function:
    root@/tmp$ node_cd(){ cd /path/to/directory; ./helloword; }

    root@/tmp$ node_cd
    Hello World
    root@/path/to/directory $