node.js - 尝试通过 npm 安装 firebase-admin 时出错

标签 node.js firebase msbuild npm-install firebase-admin

我尝试安装 firebase-admin 时遇到错误:

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:\Users\TOYANSK\AppData\Roaming\npm\node_modules\npm\node_modules\node-
gyp\lib\build.js:258:23)
gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Windows_NT 10.0.16299
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\TOYANSK\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "build" "--fallback-to-build" "--library=static_library" "--module=C:\\Users\\TOYANSK\\Documents\\Projects\\people\\functions\\node_modules\\grpc\\src\\node\\extension_binary\\node-v48-win32-x64-unknown\\grpc_node.node" "--module_name=grpc_node" "--module_path=C:\\Users\\TOYANSK\\Documents\\Projects\\people\\functions\\node_modules\\grpc\\src\\node\\extension_binary\\node-v48-win32-x64-unknown"
gyp ERR! cwd C:\Users\TOYANSK\Documents\Projects\people\functions\node_modules\grpc
gyp ERR! node -v v6.11.2
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute 'C:\Program 
Files\nodejs\node.exe C:\Users\TOYANSK\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js build --fallback-to-build --library=static_library --module=C:\Users\TOYANSK\Documents\Projects\people\functions\node_modules\grpc\src\node\extension_binary\node-v48-win32-x64-unknown\grpc_node.node --module_name=grpc_node --module_path=C:\Users\TOYANSK\Documents\Projects\people\functions\node_modules\grpc\src\node\extension_binary\node-v48-win32-x64-unknown' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (C:\Users\TOYANSK\Documents\Projects\people\functions\node_modules\grpc\node_modules\node-pre-gyp\lib\util\compile.js:83:29)
node-pre-gyp ERR! stack     at emitTwo (events.js:106:13)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:891:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
node-pre-gyp ERR! System Windows_NT 10.0.16299
node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\TOYANSK\\Documents\\Projects\\people\\functions\\node_modules\\grpc\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build" "--library=static_library"
node-pre-gyp ERR! cwd C:\Users\TOYANSK\Documents\Projects\people\functions\node_modules\grpc
node-pre-gyp ERR! node -v v6.11.2
node-pre-gyp ERR! node-pre-gyp -v v0.6.39
node-pre-gyp ERR! not ok
Failed to execute 'C:\Program Files\nodejs\node.exe C:\Users\TOYANSK\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js build --fallback-to-build --library=static_library --module=C:\Users\TOYANSK\Documents\Projects\people\functions\node_modules\grpc\src\node\extension_binary\node-v48-win32-x64-unknown\grpc_node.node --module_name=grpc_node --module_path=C:\Users\TOYANSK\Documents\Projects\people\functions\node_modules\grpc\src\node\extension_binary\node-v48-win32-x64-unknown' (1)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! grpc@1.7.3 install: `node-pre-gyp install --fallback-to-build --library=static_library`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the grpc@1.7.3 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\TOYANSK\AppData\Roaming\npm-cache\_logs\2018-02-09T23_37_53_013Z-debug.log

为了解决这个问题,我尝试了很多方法,目前还没有成功:

但最终结果没有任何改变。我使用 Windows 10 64 位、Node.js v6.11.2(当时是 8.4.0)、NPM 5.6.0。

一个奇怪的事实是,该错误也发生在 firebase init 期间,即使在 npm install 中出现错误后仍允许继续。 也许由于这个原因,之前没有安装 firebase-admin,即使位于 functions 目录的 package.json

最佳答案

如果您尝试按照 this answer 中的建议在 Powershell 中以管理员身份运行 npm install -g windows-build-tools 会怎样? ?

您的堆栈跟踪包括node-pre-gyp ERR!堆栈错误:无法执行 'C:\Program Files\nodejs\node.exe C:\Users\TOYANSK\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js build ... 这很可能意味着您没有安装 node-gyp 库。

答案所解决的问题的标题是需要node-gyp的npm安装在Windows上失败

关于node.js - 尝试通过 npm 安装 firebase-admin 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48715900/

相关文章:

msbuild - 使用AssemblyInfo自动更新多个AssemblyInfo.cs文件

json - 如何阻止 Python 的 Requests 库去除转义字符?

node.js - webpack 仅捆绑 firebase/database 而不是 firebase/auth

android - 尝试在 builder.setPositiveButton 的 onClick() 方法中放置一些代码时获取 'Cannot resolve method ' addOnCompletionListener( )'.......'

.net - 两个引用程序集之间的冲突

delphi - msbuild:如何选择应用程序商店进行配置

c++ - 带有 NodeJS 订阅者的 ZMQ 发布者服务器

javascript - 如何使用Express和MongoDB将json从nodejs服务器发送到客户端js文件

node.js - Nodejs Exec不执行

android - 将 Firebase 数据库中的值加载到 Android 中的下拉 TextView 中