如何从python脚本安装npm包?

Vla*_*kov 8 python node.js npm sublimetext2

如何从 python 脚本安装 npm 包?

当我使用 subprocess.Popen(["node", "app.js"])它时就可以了
当我使用 subprocess.Popen(["npm", "install", "open"])它时抛出错误

抱歉,Google 和 DuckDuckGo 今天不是我的朋友(

主要问题- 自动本地安装需要我的小实用程序包,因为全局包在 Windows 中不起作用。

附注。我必须问这个问题,因为我正在尝试为 Sublime Text 2 开发一个插件。

这是Sublime python 控制台中错误

Reloading plugin …\stsync.py
Traceback (most recent call last):
  File ".\sublime_plugin.py", line 103, in create_application_commands
    cmds.append(class_())
  File ".\stsync.py", line 16, in __init__
  File ".\subprocess.py", line 633, in __init__
  File ".\subprocess.py", line 842, in _execute_child
WindowsError: [Error 2] 
Run Code Online (Sandbox Code Playgroud)

第 16 行: subprocess.Popen(["node", "npm", "install", "open"])


如果我将第 16 行更改subprocess.Popen(["node", "npm", "install", "open"]) 然后 python 脚本将成功调用 nodejs 终端,但它会失败并出现错误:
cannot find npm module
节点错误

Eva*_*oky 5

shell参数设置为 True

subprocess.Popen(["node", "npm", "install", "open"], shell=True)
Run Code Online (Sandbox Code Playgroud)