dow57588 2018-01-10 20:37
浏览 444
已采纳

从golang程序安装npm

I need to run npm install on folder that I was created

Im doing the following

command := exec.Command("../app/node/", "npm", "install")
command.Dir = "."
output, err := command.Output()
if err != nil {
    log.Println(err)
}
fmt.Printf("%s", output)

And I get error :

fork/exec ../app/node/: permission denied

Any idea how to overcome this?

  • 写回答

2条回答 默认 最新

  • duanfei1975 2018-01-10 20:45
    关注

    You've got your arguments to Command in the wrong order. Per the documentation, the first argument is the program to be executed (i.e. npm), the following arguments are the parameters to pass, in the order that command should receive them, e.g.:

    command := exec.Command("npm", "install", "../app/node/")
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?