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?

4

1 回答 1

0

cd是一个内置的 shell 命令。尝试运行

/usr/bin/cd /dir

从你的外壳;你会发现它什么也没做。同样,cd从 Node 运行也没有效果。

cd您应该使用 更改工作目录,而不是生成process.chdir.

于 2012-05-19T14:28:02.357 回答