【问题标题】:Not able to install npm package PM2 in windows 7无法在 Windows 7 中安装 npm 包 PM2
【发布时间】:2014-01-11 14:08:47
【问题描述】:

无法在 Windows 7 中安装 npm 包 PM2,我们遇到以下错误

> usage@0.3.9 install C:\Users\evaith\AppData\Roaming\npm\node_modules\pm2\node_modules\usage
> node-gyp rebuild


C:\Users\evaith\AppData\Roaming\npm\node_modules\pm2\node_modules\usage>node "C:\Program Files\nodejs\node_modules\npm\b
in\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack     at failNoPython (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:118:
14)
gyp ERR! stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:81:11
gyp ERR! stack     at Object.oncomplete (fs.js:107:15)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "node" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuil
d"
gyp ERR! cwd C:\Users\evaith\AppData\Roaming\npm\node_modules\pm2\node_modules\usage
gyp ERR! node -v v0.10.21
gyp ERR! node-gyp -v v0.10.10
gyp ERR! not ok
npm ERR! weird error 1
npm http 304 https://registry.npmjs.org/keypress
npm ERR! not ok code 0
PS C:\Users\evaith>

为什么要寻找 Python 路径。

【问题讨论】:

  • 我想,你需要先安装python。linklink
  • 注意windows中的pm2。目前仅适用于 Linux 和 MacOS。在 github 或 this issue 中查看项目
  • 你最好在 linux 上开发。许多具有非 JS 代码(主要是 c++)的 npm 模块并不是为在 windows 上工作而构建的。

标签: node.js npm


【解决方案1】:

PM2 使用需要编译的本地组件。许多 node 包使用 node-gyp (reference) 使构建原生 C/C++ 代码跨平台更加方便和可靠。

node-gyp的依赖之一是Python的2.7.3+系列(3.x不兼容)。因此,为了编译一个尚未包含本机二进制文件或回退到 JavaScript 的包,您可能需要 Python。但是,如果你在 Windows 上编译,你还需要一个编译器。我建议按照node-gyp 网页上的说明进行操作(您需要安装 Visual Studio 的免费版本)。

但是,稍后您会遇到更严重的错误,即 Windows 不支持 PM2 ( https://github.com/Unitech/pm2/issues/6?source=cc)。

【讨论】:

    【解决方案2】:

    错误:找不到 Python 可执行文件“python”,您可以设置 PYTHON 环境变量。

    安装python? Get it here

    【讨论】:

    • 为什么PM2要找python?
    • node-gyp,大概它的一个依赖项需要用它编译一些东西。
    猜你喜欢
    • 2017-08-27
    • 1970-01-01
    • 1970-01-01
    • 2019-12-01
    • 1970-01-01
    • 2017-12-12
    • 1970-01-01
    相关资源
    最近更新 更多