0

I tried to change the directory using a normal cd command, but it says execvp(): No such file or directory.

These are the lines:

fs = require 'fs'

util = require 'util'
{spawn} = require 'child_process'

clientTest = (callback) ->
  d = spawn 'cd', ['client']
  d.stderr.on 'data', (data) ->
    process.stderr.write data.toString()
  d.stdout.on 'data', (data) ->
    util.log data.toString()
  d.on 'exit', (code) ->
    callback?() if code is 0

I'm guessing I have to do something withe the filesystem?

prashn64
  • 657
  • 1
  • 8
  • 24

1 Answers1

0

cd is a built-in shell command. Try running

/usr/bin/cd /dir

from your shell; you'll find that it doesn't do anything. Likewise, running cd from Node has no effect.

Instead of spawning cd, you should change the working directory with process.chdir.

Trevor Burnham
  • 76,828
  • 33
  • 160
  • 196