我正在构建一个生成器,最后我需要在应用程序的某个目录中进行npm install
,我尝试了以下操作:
this.spawnCommandSync('cd', [this.destinationRoot() + '/my/folder'])
this.spawnCommandSync('npm', ['install'])
但它不起作用。
并且 npm install
不能在不同的目录中调用,也不能在任何 yeoman install mixins 中调用。 .
最佳答案
传递选项cwd
- 就像 https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options
关于yeoman - 选择在 Yeoman 中生成命令的位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33160904/