【问题标题】:Using node module with react native使用带有 react native 的 node 模块
【发布时间】:2017-09-26 02:36:18
【问题描述】:

正如here提到的那样,

任何纯 javascript 并在 node.js/io.js 中运行的模块都可以在 react-native 中运行。

我需要在 react native 中调整和裁剪图像,所以我尝试使用 nodejs sharp 图像处理库,我认为它应该与 reactnative 一起使用,因为它在纯节点中并与 io 事物一起使用。

但是在安装的时候会报错:

PS D:\ReactNative\f_sandbox> npm install sharp

> sharp@0.17.3 install D:\ReactNative\f_sandbox\node_modules\sharp
> node-gyp rebuild


D:\ReactNative\f_sandbox\node_modules\sharp>if not defined npm_config_node_gyp (node "G:\Installed\Node\node_modules\npm\bin\node-gyp-bin\\..\..\node_modul
es\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.
MSBUILD : error MSB3428: Could not load the Visual C++ component "VCBuild.exe". To fix this, 1) install the .NET Framework 2.0 SDK, 2) install Microsoft Visua
l Studio 2005 or 3) add the location of the component to the system path if it is installed elsewhere.  [D:\ReactNative\f_sandbox\node_modules\sharp\build
\binding.sln]
gyp ERR! build error
gyp ERR! stack Error: `C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (G:\Installed\Node\node_modules\npm\node_modules\node-gyp\lib\build.js:276: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.15063
gyp ERR! command "G:\\Installed\\Node\\node.exe" "G:\\Installed\\Node\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd D:\ReactNative\f_sandbox\node_modules\sharp
gyp ERR! node -v v6.9.2
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
npm ERR! Windows_NT 10.0.15063
npm ERR! argv "G:\\Installed\\Node\\node.exe" "G:\\Installed\\Node\\node_modules\\npm\\bin\\npm-cli.js" "install" "sharp"
npm ERR! node v6.9.2
npm ERR! npm  v3.10.9
npm ERR! code ELIFECYCLE

npm ERR! sharp@0.17.3 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sharp@0.17.3 install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the sharp package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs sharp
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls sharp
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     D:\ReactNative\f_sandbox\npm-debug.log

这个/这里缺少什么有什么解决办法吗?

【问题讨论】:

    标签: node.js react-native


    【解决方案1】:

    这不是您的应用程序的问题,而是特定于 npm 的问题。您需要使用正确的 msvs_version 标志来安装需要 node-gyp 的 io 包。

    这不是一个很好的测试,但首先请在你的机器上找到 .net 框架的版本。

    接下来使用版本如下

    npm install socket.io --msvs_version=2012
    

    注意:您的包名可能不同

    【讨论】:

      猜你喜欢
      • 2015-10-13
      • 1970-01-01
      • 2013-11-11
      • 2019-01-07
      • 1970-01-01
      • 2020-04-29
      • 2015-05-17
      • 2021-08-13
      • 1970-01-01
      相关资源
      最近更新 更多