从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?

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/")

The format for executing a command using Command is as follows c := exec.Command(<command>,<args>...) In your case the command is npm. Therefore the code should be like the following and you can bind stdout and stderr of the command to shell.So that you can view npm logs.

command := exec.Command("../app/node/npm","install")
command.Stdout = os.Stdout
command.Stderr = os.Stderr
// Run the command
command.Run()