node.js - 无法在 Windows 7 中安装 npm 包 PM2

标签 node.js npm

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

> <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d6a3a5b7b1b396e6f8e5f8ef" rel="noreferrer noopener nofollow">[email protected]</a> 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路径。

最佳答案

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

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

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

关于node.js - 无法在 Windows 7 中安装 npm 包 PM2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20742141/

相关文章:

node.js - "ng new xxx"给出错误错误代码-4048

node.js - 使用 socket.io 将文件从字符串发送到浏览器

javascript - Node.js events.js : 163 throw er; when executing Jest with flag --runInBand

node.js - 使用 sails.js 和 sails-postgresql 的数据库模式

node.js - 找不到模块 '@babel/core'

npm - 如何修复 Npm 缺少对等依赖项

node.js - 运行建议的命令并不能修复 NPM 漏洞

javascript - 将变量注入(inject)函数的范围

node.js - 使用 RDS 时性能不佳的 AWS Lambda

node.js - 获取 "Invalid parameter: redirect_uri"尝试使用 KeyCloak 进行 NODE.JS 身份验证