错误:找不到模块'ffi'编译ElectronJS项目 [英] Error: Cannot find module 'ffi' compiling ElectronJS project

查看:40
本文介绍了错误:找不到模块'ffi'编译ElectronJS项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是NodeJS/ElectronJS的新手.我需要使用User.dll函数.我的实际情况是:

I'm new on NodeJS/ElectronJS. I need to use User.dll functions. My actual situation is:

Parallels上的Windows 10节点-v = 10.15.3(LTS)NPM -v = 6.9.0

Windows 10 on Parallels Node -v = 10.15.3 (LTS) NPM -v = 6.9.0

我已安装:

npm install --global --production windows-build-tools

npm install win32-api

npm install ffi (gives me several "\ffi.cc(***): warning C4996: 'v8::Value::To Object': .... deprecated)

我添加了var FFI = require('node-ffi');在我的"main.js"中,当我尝试使用npm start进行编译

I added var FFI = require('node-ffi'); in my "main.js" and when I try to compile with npm start

我收到此错误:

Error: Cannot find module 'node-ffi' at Module._resolveFilename (internal/modules/cjs/loader.js:584:15)

怎么了?

推荐答案

以下步骤解决了我的问题(***中的主要痛苦)

The following steps fixed my issue (major pain in the ***)

确保已安装节点gyp编译器

Make sure the node gyp compiler is installed

npm install -g node-gyp

将FFI软件包安装到本地项目中

Install the FFI package into the local project

npm install --save ffi

我还需要安装ref-array(示例代码的一部分)

I also needed to install ref-array (part of example code)

npm install ref-array --save

进入node_modules/ffi目录并进行NPM安装,以确保它具有所有依赖项

Go into the node_modules/ffi directory and do an NPM install to make sure it's got all it's dependencies

cd node_modules/ffi
npm install

退出node_modules/ffi文件夹

Get back out of the node_modules/ffi folder

cd ../../

安装电子重建工具

npm install --save-dev electron-rebuild

运行电子重建脚本(我在Windows上运行,因此是.cmd)

Run the electron rebuild script (I'm running on Windows, hence .cmd)

.\node_modules\.bin\electron-rebuild.cmd

那么简单(不):D

这篇关于错误:找不到模块'ffi'编译ElectronJS项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆