Node.js 未能在我的本机应用程序上安装域;与:npm错误!失败realm@3.6.0安装脚本';节点预gyp安装--回退到构建';

Node.js 未能在我的本机应用程序上安装域;与:npm错误!失败realm@3.6.0安装脚本';节点预gyp安装--回退到构建';,node.js,react-native,npm,realm,Node.js,React Native,Npm,Realm,我正在尝试使用npm为我的React本机应用程序安装Realm。然而,我没能成功 我的环境/设置是: 视窗10 Node.js v12.13.0 npm v6.13.0 我一直在尝试使用此命令: npm安装--保存领域 或指定版本号: npm安装--保存realm@3.6.0 但是一点运气都没有。以下错误消息始终提示我,但没有明确提示: > realm@3.6.0 install C:\Projects\<ProjectFolder>\node_modules\realm

我正在尝试使用npm为我的React本机应用程序安装Realm。然而,我没能成功

我的环境/设置是:

  • 视窗10
  • Node.js v12.13.0
  • npm v6.13.0
我一直在尝试使用此命令:
npm安装--保存领域

或指定版本号:
npm安装--保存realm@3.6.0

但是一点运气都没有。以下错误消息始终提示我,但没有明确提示:

> realm@3.6.0 install C:\Projects\<ProjectFolder>\node_modules\realm
> node-pre-gyp install --fallback-to-build

node-pre-gyp WARN Using request for node-pre-gyp https download
node-pre-gyp WARN Tried to download(404): https://static.realm.io/node-pre-gyp/3.6.0/realm-v3.6.0-node-v72-win32-x64.tar.gz
node-pre-gyp WARN Pre-built binaries not found for realm@3.6.0 and node@12.13.0 (node-v72 ABI, unknown) (falling back to source compile with node-gyp)
gyp ERR! find VS
gyp ERR! find VS msvs_version not set from command line or npm config
gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
gyp ERR! find VS looking for Visual Studio 2015
gyp ERR! find VS - not found
gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
gyp ERR! find VS
gyp ERR! find VS **************************************************************
gyp ERR! find VS You need to install the latest version of Visual Studio
gyp ERR! find VS including the "Desktop development with C++" workload.
gyp ERR! find VS For more information consult the documentation at:
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
gyp ERR! find VS **************************************************************
gyp ERR! find VS
gyp ERR! configure error
gyp ERR! stack Error: Could not find any Visual Studio installation to use
gyp ERR! stack     at VisualStudioFinder.fail (C:\Users\<UserName>\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:121:47)
gyp ERR! stack     at C:\Users\<UserName>\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:74:16
gyp ERR! stack     at VisualStudioFinder.findVisualStudio2013 (C:\Users\<UserName>\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:351:14)
gyp ERR! stack     at C:\Users\<UserName>\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:70:14
gyp ERR! stack     at C:\Users\<UserName>\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:372:16
gyp ERR! stack     at C:\Users\<UserName>\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\util.js:54:7
gyp ERR! stack     at C:\Users\<UserName>\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\util.js:33:16
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:302:5)
gyp ERR! stack     at ChildProcess.emit (events.js:210:5)
gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
gyp ERR! System Windows_NT 10.0.18362
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\<UserName>\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "configure" "--fallback-to-build" "--module=C:\\Projects\\<ProjectFolder>\\node_modules\\realm\\compiled\\node-v72_win32_x64\\realm.node" "--module_name=realm" "--module_path=C:\\Projects\\<ProjectFolder>\\node_modules\\realm\\compiled\\node-v72_win32_x64" "--napi_version=5" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v72"
gyp ERR! cwd C:\Projects\<ProjectFolder>\node_modules\realm
gyp ERR! node -v v12.13.0
gyp ERR! node-gyp -v v5.0.5
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\<UserName>\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js configure --fallback-to-build --module=C:\Projects\<ProjectFolder>\node_modules\realm\compiled\node-v72_win32_x64\realm.node --module_name=realm --module_path=C:\Projects\<ProjectFolder>\node_modules\realm\compiled\node-v72_win32_x64 --napi_version=5 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (C:\Projects\<ProjectFolder>\node_modules\realm\node_modules\node-pre-gyp\lib\util\compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:210:5)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
node-pre-gyp ERR! System Windows_NT 10.0.18362
node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Projects\\<ProjectFolder>\\node_modules\\realm\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd C:\Projects\<ProjectFolder>\node_modules\realm
node-pre-gyp ERR! node -v v12.13.0
node-pre-gyp ERR! node-pre-gyp -v v0.13.0
node-pre-gyp ERR! not ok
Failed to execute 'C:\Program Files\nodejs\node.exe C:\Users\<UserName>\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js configure --fallback-to-build --module=C:\Projects\<ProjectFolder>\node_modules\realm\compiled\node-v72_win32_x64\realm.node --module_name=realm --module_path=C:\Projects\<ProjectFolder>\node_modules\realm\compiled\node-v72_win32_x64 --napi_version=5 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72' (1)
npm WARN @typescript-eslint/eslint-plugin@1.13.0 requires a peer of eslint@^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @typescript-eslint/parser@1.13.0 requires a peer of eslint@^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN aws-amplify-react-native@2.2.3 requires a peer of graphql@0.13.0 but none is installed. You must install peer dependencies yourself.
npm WARN aws-amplify-react-native@2.2.3 requires a peer of react-native-sound@^0.10.9 but none is installed. You must install peer dependencies yourself.
npm WARN aws-amplify-react-native@2.2.3 requires a peer of react-native-voice@^0.2.6 but none is installed. You must install peer dependencies yourself.
npm WARN react-native-elements@0.19.1 requires a peer of react-native-vector-icons@^4.2.0 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-plugin-react@7.12.4 requires a peer of eslint@^3.0.0 || ^4.0.0 || ^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-plugin-react-native@3.6.0 requires a peer of eslint@^3.17.0 || ^4 || ^5 but none is installed. You must install peer dependencies yourself.
npm WARN react-native-fs@2.16.2 requires a peer of react-native@^0.59.5 but none is installed. You must install peer dependencies yourself.
npm WARN react-native-fs@2.16.2 requires a peer of react-native-windows@^0.57.2 but none is installed. You must install peer dependencies yourself.
npm WARN tsutils@3.17.1 requires a peer of typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! realm@3.6.0 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the realm@3.6.0 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\<UserName>\AppData\Roaming\npm-cache\_logs\2019-12-21T10_36_02_380Z-debug.log
>realm@3.6.0安装C:\Projects\\node\u modules\realm
>节点预gyp安装--回退到构建
使用节点预gyp https下载请求发出节点预gyp警告
尝试下载节点前gyp警告(404):https://static.realm.io/node-pre-gyp/3.6.0/realm-v3.6.0-node-v72-win32-x64.tar.gz
未找到的节点pre-gyp WARN预构建二进制文件realm@3.6.0及node@12.13.0(node-v72 ABI,未知)(使用node-gyp返回到源代码编译)
哎呀!查找VS
哎呀!查找未从命令行或npm配置设置的VS msvs_版本
哎呀!查找VS VCINSTALLDIR未设置,未在VS命令提示符下运行
哎呀!find VS无法使用PowerShell查找Visual Studio 2017或更高版本
哎呀!查找VS查找Visual Studio 2015
哎呀!查找VS-未找到
哎呀!查找VS不查找VS2013,因为它最多只支持Node.js 8
哎呀!查找VS
哎呀!查找VS**************************************************************
哎呀!查找需要安装最新版本Visual Studio的VS
哎呀!查找包含“使用C++进行桌面开发”工作负载的VS。
哎呀!查找VS有关更多信息,请参阅以下文档:
哎呀!查找VShttps://github.com/nodejs/node-gyp#on-窗户
哎呀!查找VS**************************************************************
哎呀!查找VS
哎呀!配置错误
哎呀!堆栈错误:找不到任何要使用的Visual Studio安装
哎呀!VisualStudioFinder.fail处的堆栈(C:\Users\\AppData\Roaming\npm\node\u modules\npm\node\u modules\node gyp\lib\find visualstudio.js:121:47)
哎呀!堆栈位于C:\Users\\AppData\Roaming\npm\node\u modules\npm\node\u modules\node gyp\lib\find visualstudio.js:74:16
哎呀!堆栈位于VisualStudioFinder.FindVisualStudio 2013(C:\Users\\AppData\Roaming\npm\node\U modules\npm\node\U modules\node gyp\lib\find visualstudio.js:351:14)
哎呀!堆栈位于C:\Users\\AppData\Roaming\npm\node\u modules\npm\node\u modules\node gyp\lib\find visualstudio.js:70:14
哎呀!堆栈位于C:\Users\\AppData\Roaming\npm\node\u modules\npm\node\u modules\node gyp\lib\find visualstudio.js:372:16
哎呀!堆栈位于C:\Users\\AppData\Roaming\npm\node\u modules\npm\node\u modules\node gyp\lib\util.js:54:7
哎呀!堆栈位于C:\Users\\AppData\Roaming\npm\node\u modules\npm\node\u modules\node gyp\lib\util.js:33:16
哎呀!ChildProcess.exithandler处的堆栈(child_process.js:302:5)
哎呀!ChildProcess.emit上的堆栈(events.js:210:5)
哎呀!maybeClose的堆栈(内部/child_process.js:1021:16)
哎呀!系统Windows\u NT 10.0.18362
哎呀!命令“C:\\Program Files\\nodejs\\node.exe”“C:\\Users\\\\AppData\\Roaming\\npm\\node\U modules\\npm\\node\U modules\\node gyp\\bin\\node gyp.js”“configure”“--fallback to build”“--module=C:\\Projects\\\node\U modules\\realm\\compiled\\node-v72\u win32\u x64\\realm.node”“--\module\u name=realm”“--module\u path=C:\\Projects\\\\node\u modules\\realm\\compiled\\node-v72\u win32\u x64”“--napi\u version=5”“--node\u abi\u napi=napi”“--napi\u build\u version=0”“--node\u napi\u label=node-v72”
gyp ERR!cwd C:\Projects\\node\u modules\realm
GypErr!节点-v12.13.0
gyp ERR!节点gyp-v5.0.5
哎呀!不行
节点预gyp错误!生成错误
节点前gyp错误!堆栈错误:未能执行'C:\Program Files\nodejs\node.exe C:\Users\\AppData\Roaming\npm\node\U modules\node gyp\bin\node-gyp.js configure--回退到构建--模块=C:\Projects\\node\modules\realm\compiled\node-v72\U win32\U x64\realm.node--模块名=realm--模块路径=C:\Projects\\node\modules\realm\compiled\compiled\node-v72\u win32\u x64--napi\u版本=5--node\u abi\u napi=napi--napi\u构建\u版本=0--node\u napi\u标签=node-v72'(1)
节点预gyp ERR!在子进程上堆栈。)
,旧的成功版本系列是0.x.0(例如0.14.0),甚至不是1.x.x,与最新的稳定版本相比,1.x.x已经过时了

这里有类似错误消息的讨论怀疑这是一个bug:

然后我来到了这篇文章,它建议将整个NodeJS回退到8.x.x版本,以便尝试一下:


这是将Realm安装到我的React本机应用程序的唯一方法吗?当我在安装了NodeJS v12.13.0的Windows 10环境中开发时,我发现回退过程/在不同NodeJS版本之间切换是复杂的,或者只在Mac OS/Linux OS上可行。我担心fallba可能还有其他副作用检查全局NodeJS版本。

我进一步阅读了NPM上Realm的详细信息:

有一条语句指示v8或v10节点的必要性:

入门

请参阅我们文档中关于使用领域Javascript的详细说明。请注意,目前仅支持node.js版本8和10

因此,我决定不再修改全局NPM版本,而是尝试安装一个包级节点v10.x.x(即在项目文件夹中运行
NPM install
,但不运行
NPM install-g
),然后再次尝试安装Realm。它就像魔术一样工作

因此,让我在这里为那些对同样情况感到恼火的人分享以下步骤:

  • cd到项目文件夹
  • 运行
    npm安装node@10.x.x
    (例如,
    npm安装node@10.17.0
  • 运行npm安装--save realmC:\Projects\<ProjectFolder>>npm install node@10.17.0 > node@10.17.0 preinstall C:\Projects\<ProjectFolder>\node_modules\node > node installArchSpecificPackage + node-win-x64@10.17.0 added 1 package in 1.715s npm WARN @typescript-eslint/eslint-plugin@1.13.0 requires a peer of eslint@^5.0.0 but none is installed. You must install peer dependencies yourself. npm WARN @typescript-eslint/parser@1.13.0 requires a peer of eslint@^5.0.0 but none is installed. You must install peer dependencies yourself. npm WARN aws-amplify-react-native@2.2.3 requires a peer of graphql@0.13.0 but none is installed. You must install peer dependencies yourself. npm WARN aws-amplify-react-native@2.2.3 requires a peer of react-native-sound@^0.10.9 but none is installed. You must install peer dependencies yourself. npm WARN aws-amplify-react-native@2.2.3 requires a peer of react-native-voice@^0.2.6 but none is installed. You must install peer dependencies yourself. npm WARN react-native-elements@0.19.1 requires a peer of react-native-vector-icons@^4.2.0 but none is installed. You must install peer dependencies yourself. npm WARN eslint-plugin-react@7.12.4 requires a peer of eslint@^3.0.0 || ^4.0.0 || ^5.0.0 but none is installed. You must install peer dependencies yourself. npm WARN eslint-plugin-react-native@3.6.0 requires a peer of eslint@^3.17.0 || ^4 || ^5 but none is installed. You must install peer dependencies yourself. npm WARN react-native-fs@2.16.2 requires a peer of react-native@^0.59.5 but none is installed. You must install peer dependencies yourself. npm WARN react-native-fs@2.16.2 requires a peer of react-native-windows@^0.57.2 but none is installed. You must install peer dependencies yourself. npm WARN tsutils@3.17.1 requires a peer of typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta but none is installed. You must install peer dependencies yourself. npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}) + node@10.17.0 added 2 packages from 1 contributor and audited 953911 packages in 19.807s 2 packages are looking for funding. Run "npm fund" to find out more.
  • C:\Projects\<ProjectFolder>>npm install --save realm@3.6.0
    
    > realm@3.6.0 install C:\Projects\<ProjectFolder>\node_modules\realm
    > node-pre-gyp install --fallback-to-build
    
    node-pre-gyp WARN Using request for node-pre-gyp https download
    [realm] Success: "C:\Projects\<ProjectFolder>\node_modules\realm\compiled\node-v64_win32_x64\realm.node" is installed via remote
    npm WARN @typescript-eslint/eslint-plugin@1.13.0 requires a peer of eslint@^5.0.0 but none is installed. You must install peer dependencies yourself.
    npm WARN @typescript-eslint/parser@1.13.0 requires a peer of eslint@^5.0.0 but none is installed. You must install peer dependencies yourself.
    npm WARN aws-amplify-react-native@2.2.3 requires a peer of graphql@0.13.0 but none is installed. You must install peer dependencies yourself.
    npm WARN aws-amplify-react-native@2.2.3 requires a peer of react-native-sound@^0.10.9 but none is installed. You must install peer dependencies yourself.
    npm WARN aws-amplify-react-native@2.2.3 requires a peer of react-native-voice@^0.2.6 but none is installed. You must install peer dependencies yourself.
    npm WARN react-native-elements@0.19.1 requires a peer of react-native-vector-icons@^4.2.0 but none is installed. You must install peer dependencies yourself.
    npm WARN eslint-plugin-react@7.12.4 requires a peer of eslint@^3.0.0 || ^4.0.0 || ^5.0.0 but none is installed. You must install peer dependencies yourself.
    npm WARN eslint-plugin-react-native@3.6.0 requires a peer of eslint@^3.17.0 || ^4 || ^5 but none is installed. You must install peer dependencies yourself.
    npm WARN react-native-fs@2.16.2 requires a peer of react-native@^0.59.5 but none is installed. You must install peer dependencies yourself.
    npm WARN react-native-fs@2.16.2 requires a peer of react-native-windows@^0.57.2 but none is installed. You must install peer dependencies yourself.
    npm WARN tsutils@3.17.1 requires a peer of typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta but none is installed. You must install peer dependencies yourself.
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules\fsevents):
    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
    
    + realm@3.6.0
    added 62 packages from 32 contributors, removed 1 package and audited 954332 packages in 52.277s
    
    2 packages are looking for funding.
    Run "npm fund" to find out more.