【问题标题】:npm install bcrypt, gyp ERR! pythonnpm install bcrypt, gyp 错误! Python
【发布时间】:2016-11-18 20:32:33
【问题描述】:

在 Windows 10 节点:v6.7.0、npm:v4.0.1 节点-gyp:v3.4.0 上,我正在尝试 npm install --save bcrypt 我面临这些错误。这就是我在我的路径中同时拥有 python27 和 python35-32 的地方。

D:\myApp\node_modules\bcrypt>if not defined npm_config_node_gyp (node "C:\Users\myname\AppData\Roaming\npm\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "" rebuild )
gyp ERR! configure error
gyp ERR! stack Error: Python executable "C:\Users\myname\AppData\Local\Programs\Python\Python35-32\python.EXE" is v3.5.2, which is not supported by gyp.
gyp ERR! stack You can pass the --python switch to point to Python >= v2.5.0 & < 3.0.0.
gyp ERR! stack     at failPythonVersion (C:\Users\Amirhossein\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\configure.js:454:14) ....

我尝试用npm install --save --python=phyton2.7 bcrypt安装

看起来不错,但安装完成后出现很多警告:

D:\myApp\node_modules\bcrypt>if not defined npm_config_node_gyp (node "C:\Users\myname\AppData\Roaming\npm\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "" rebuild )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
  blowfish.cc
  bcrypt.cc
  bcrypt_node.cc
  win_delay_load_hook.cc
..\src\bcrypt.cc(232): warning C4267: '=': conversion from 'size_t' to 'unsigned char', possible loss of data [D:\myApp\node_modules\bcrypt\build\bcrypt_lib.vcxproj]
..\src\bcrypt_node.cc(76): warning C4244: 'argument': conversion from 'ssize_t' to 'unsigned char', possible loss of data [D:\myApp\node_modules\bcrypt\build\bcrypt_lib.vcxproj]
..\src\bcrypt_node.cc(229): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data [D:\myApp\node_modules\bcrypt\build\bcrypt_lib.vcxproj]
..\src\bcrypt_node.cc(230): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data [D:\myApp\node_modules\bcrypt\build\bcrypt_lib.vcxproj]

它会正常工作吗?安装 bcrypt 的正确方法是什么?我应该在 node-gyp 修改配置吗?

【问题讨论】:

    标签: python node.js bcrypt npm-install node-gyp


    【解决方案1】:

    您也可以在您的操作系统中安装 Python2.x 并运行:

    npm config set python /path/to/python2.x
    

    这解决了我的问题,希望对某人有所帮助。

    【讨论】:

      【解决方案2】:

      如果您愿意放弃 bcrypt,我建议使用bcryptjs,它与零依赖的 bcrypt 兼容。 是的,这将导致performance hit,但如果你对此感到满意,它将让你摆脱 node-gyp 重建地狱。

      【讨论】:

        【解决方案3】:

        最简单的解决方案:放弃 python bcrypt 并改用 bcrypt-nodejs:https://github.com/shaneGirish/bcrypt-nodejs

        【讨论】:

        • 这个功能等效吗?
        • 恕我直言,如果您不关心性能,那很好(是的,我知道 bcrypt 的目的,但是在纯 javascript 中执行 bcrypt 时仍然存在不必要的性能影响)。
        • npm WARN deprecated bcrypt-nodejs@0.0.3: bcrypt-nodejs is no longer actively maintained. Please use bcrypt or bcryptjs. See https://github.com/kelektiv/node.bcrypt.js/wiki/bcrypt-vs-brypt.js to learn more about these two options
        猜你喜欢
        • 1970-01-01
        • 2017-02-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-09-17
        • 2018-02-07
        • 2019-12-22
        相关资源
        最近更新 更多