gpt4 book ai didi

node.js - 错误: Cannot find module 'ffi' compiling ElectronJS project

转载 作者:行者123 更新时间:2023-12-03 12:26:08 24 4
gpt4 key购买 nike

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

Windows 10在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进行编译时

我收到此错误:
Error: Cannot find module 'node-ffi' at Module._resolveFilename (internal/modules/cjs/loader.js:584:15)

怎么了?

最佳答案

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

确保已安装 Node gyp编译器

npm install -g node-gyp

将FFI软件包安装到本地项目
npm install --save ffi

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

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

退出node_modules/ffi文件夹
cd ../../

安装 Electron 重建工具
npm install --save-dev electron-rebuild

运行 Electron 重建脚本(我在Windows上运行,因此是.cmd)
.\node_modules\.bin\electron-rebuild.cmd

如此简单(NOT):D

关于node.js - 错误: Cannot find module 'ffi' compiling ElectronJS project,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55613580/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com