【问题标题】:Does MongoDB node.js driver installation need Python?MongoDB node.js驱动安装需要Python吗?
【发布时间】:2015-09-20 21:00:28
【问题描述】:

我正在尝试在 Windows 10 上为 Nodejs 安装 mongodb 驱动程序并收到以下关于 Python 的错误。

Python 是先决条件吗? 而且它也只需要 Python 2.5 到 3.0 版本。 在 Python 之上,它一直要求其他 MS Visual Studio 2008 或 MS SDK/.Net 安装? 它是否需要所有这些作为先决条件。

C:\Jay\M101JS>npm install mongodb
-
> kerberos@0.0.14 install C:\Jay\M101JS\node_modules\mongodb\node_modules\mongodb-core\node_modules\kerberos
> (node-gyp rebuild) || (exit 0)


C:\Jay\M101JS\node_modules\mongodb\node_modules\mongodb-core\node_modules\kerberos>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\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: 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:116:14)
gyp ERR! stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:71:11
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:82:15)
gyp ERR! System Windows_NT 10.0.10240
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Jay\M101JS\node_modules\mongodb\node_modules\mongodb-core\node_modules\kerberos
gyp ERR! node -v v4.0.0
gyp ERR! node-gyp -v v3.0.1
gyp ERR! not ok
mongodb@2.0.43 node_modules\mongodb
├── es6-promise@2.1.1
├── readable-stream@1.0.31 (string_decoder@0.10.31, inherits@2.0.1, isarray@0.0.1, core-util-is@1.0.1)
└── mongodb-core@1.2.12 (bson@0.4.12, kerberos@0.0.14)

更新:

我在安装 Python 2.7 和 Visual Studio Express(免费)后再次尝试,现在得到以下错误,

C:\Jay\MongoDb\M101JS>npm install mongodb
-
> kerberos@0.0.14 install C:\Jay\MongoDb\M101JS\node_modules\mongodb\node_modules\mongodb-core\node_modules\kerberos
> (node-gyp rebuild) || (exit 0)


C:\Jay\MongoDb\M101JS\node_modules\mongodb\node_modules\mongodb-core\node_modules\kerberos>if not defined npm_config_node_gyp (node "C:\Program Files\
nodejs\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.
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppBuild.targets(366,5): warning MSB8003: Could not find WindowsSDKDir variable from
 the registry.  TargetFrameworkVersion or PlatformToolset may be set to an invalid version number. [C:\Jay\MongoDb\M101JS\node_modules\mongodb\node_m
odules\mongodb-core\node_modules\kerberos\build\kerberos.vcxproj]
TRACKER : error TRK0005: Failed to locate: "CL.exe". The system cannot find the file specified. [C:\Jay\MongoDb\M101JS\node_modules\mongodb\node_modu
les\mongodb-core\node_modules\kerberos\build\kerberos.vcxproj]


gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:270:23)
gyp ERR! stack     at emitTwo (events.js:87:13)
gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebui
ld"
gyp ERR! cwd C:\Jay\MongoDb\M101JS\node_modules\mongodb\node_modules\mongodb-core\node_modules\kerberos
gyp ERR! node -v v4.0.0
gyp ERR! node-gyp -v v3.0.1
gyp ERR! not ok
mongodb@2.0.43 node_modules\mongodb
├── readable-stream@1.0.31 (string_decoder@0.10.31, isarray@0.0.1, inherits@2.0.1, core-util-is@1.0.1)
├── es6-promise@2.1.1
└── mongodb-core@1.2.12 (bson@0.4.12, kerberos@0.0.14)

【问题讨论】:

    标签: python node.js mongodb installation


    【解决方案1】:

    是的,需要 Python。

    您需要安装 2.7 版。 您还需要将PYTHON 环境变量设置为例如c:\python27\python.exe(确保它可以从运行 env p 的命令行访问)

    你需要安装 Visual Studio (C++),免费的 Express 版本就可以了。

    取决于您的 Visual Studio 版本,您必须将此参数添加到您的 npm install 命令中:

    npm install --msvs_version=<version> 其中<version> 可能是201220132015

    依赖是由 Node.js MongoDb 驱动程序使用的node-gyp 引入的。可以在here 找到 Windows 的安装说明(显示的细节比这个答案略多)。

    【讨论】:

    • 非常感谢我按照您的步骤进行了尝试,但现在出现了不同的错误,我已经在问题中更新了这个。
    • CL 是 Visual Studio 编译器。也许这有帮助:blogs.msdn.com/b/deva/archive/2015/03/25/…
    • 即使在安装 Visual Studio 之后,我也遇到了类似的问题 - 我能够通过在 VS2015 命令提示符下运行“npm install mongodb”来完成安装。
    【解决方案2】:

    这个问题与mongodb驱动无关,而与node-gyp有关,node-gyp是向node添加二进制模块的工具。你可以在 stackoverflow 上找到很多答案,只需搜索 node-gyp 和 windows。您可以找到许多答案之一here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-04-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-05
      • 1970-01-01
      相关资源
      最近更新 更多