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

从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条)

报告相同问题?

悬赏问题

  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试