Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ffi-napi issue on windows while installation #2061

Open
RinkalBhojani opened this issue Oct 18, 2024 · 5 comments
Open

ffi-napi issue on windows while installation #2061

RinkalBhojani opened this issue Oct 18, 2024 · 5 comments

Comments

@RinkalBhojani
Copy link

I am facing below issue on my windows machine while installation.

@TimoGlastra @berendsliedrecht @genaris - Do you have any idea for this?

It fails to build 'ffi-napi' related package.

PS D:\Project\credo-ts> pnpm install
Scope: all 19 workspace projects
Lockfile is up to date, resolution step is skipped
Packages: +1646
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Progress: resolved 1646, reused 1646, downloaded 0, added 0, done
node_modules/.pnpm/@mattrglobal[email protected]/node_modules/@mattrglobal/node-bbs-signatnode_modules/.pnpm/@mattrglobal[email protected]/node_modules/@mattrglobal/node-bbs-signatures: Running install script, failed in 1.5s (skipped as optional)
node_modules/.pnpm/@[email protected]/node_modules/@2060.io/ffi-napi: Running install script, failed in 6s
.../node_modules/@2060.io/ffi-napi install$ node-gyp-build
│ D:\Project\credo-ts\[email protected][email protected]\[email protected]\ffi-napi>i…
│ gyp info it worked if it ends with ok
│ gyp info using [email protected]
│ gyp info using [email protected] | win32 | x64
│ gyp info find Python using Python version 3.12.6 found at "C:\Users\Rinkal Bhojani\AppData\Loca…
│ gyp info find VS using VS2022 (17.11.35303.130) found at:
│ gyp info find VS "C:\Program Files\Microsoft Visual Studio\2022\Community"
│ gyp info find VS run with --verbose for detailed information
│ gyp info spawn C:\Users\Rinkal Bhojani\AppData\Local\Programs\Python\Python312\python.exe
│ gyp info spawn args [
│ gyp info spawn args 'C:\Users\Rinkal Bhojani\AppData\Roaming\npm\node_modules\pnpm\dist…
│ gyp info spawn args 'binding.gyp',
│ gyp info spawn args '-f',
│ gyp info spawn args 'msvs',
│ gyp info spawn args '-I',
│ gyp info spawn args 'D:\Project\credo-ts\node_modules\.pnpm\@[email protected]\node_…
│ gyp info spawn args '-I',
│ gyp info spawn args 'C:\Users\Rinkal Bhojani\AppData\Roaming\npm\node_modules\pnpm\dist…
│ gyp info spawn args '-I',
│ gyp info spawn args 'C:\Users\Rinkal Bhojani\AppData\Local\node-gyp\Cache\18.20.4\inclu…
│ gyp info spawn args '-Dlibrary=shared_library',
│ gyp info spawn args '-Dvisibility=default',
│ gyp info spawn args '-Dnode_root_dir=C:\Users\Rinkal Bhojani\AppData\Local\node-gyp\Cache…
│ gyp info spawn args '-Dnode_gyp_dir=C:\Users\Rinkal Bhojani\AppData\Roaming\npm\node_modu…
│ gyp info spawn args '-Dnode_lib_file=C:\\Users\\Rinkal Bhojani\\AppData\\Local\\node-…
│ gyp info spawn args '-Dmodule_root_dir=D:\Project\credo-ts\node_modules\.pnpm\@2060.io+ffi…
│ gyp info spawn args '-Dnode_engine=v8',
│ gyp info spawn args '--depth=.',
│ gyp info spawn args '--no-parallel',
│ gyp info spawn args '--generator-output',
│ gyp info spawn args 'D:\Project\credo-ts\node_modules\.pnpm\@[email protected]\node_…
│ gyp info spawn args '-Goutput_dir=.'
│ gyp info spawn args ]
│ gyp info spawn C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBu…
│ gyp info spawn args [
│ gyp info spawn args 'build\binding.sln',
│ gyp info spawn args '/clp:Verbosity=minimal',
│ gyp info spawn args '/nologo',
│ gyp info spawn args '/p:Configuration=Release;Platform=x64'
│ gyp info spawn args ]
│ nothing.c
│ nothing.vcxproj -> D:\Project\credo-ts\[email protected][email protected]\node_module…
│ Preprocessing assembly file ......\deps\libffi\src\x86\win64_intel.preasm
│ '"call"' is not recognized as an internal or external command,
│ operable program or batch file.
│ D:\Project\credo-ts\[email protected][email protected]\[email protected]\ffi-napi\b…
│ gyp ERR! build error
│ gyp ERR! stack Error: `C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\…
│ gyp ERR! stack at ChildProcess. (C:\Users\Rinkal Bhojani\AppData\Roaming\npm\node_mo…
│ gyp ERR! stack at ChildProcess.emit (node:events:517:28)
│ gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:292:12)
│ gyp ERR! System Windows_NT 10.0.19045
│ gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\Rinkal Bhojani\AppData\Roa…
│ gyp ERR! cwd D:\Project\credo-ts\[email protected][email protected]\node_modules@2060.…
│ gyp ERR! node -v v18.20.4
│ gyp ERR! node-gyp -v v10.1.0
│ gyp ERR! not ok
└─ Failed in 6s at D:\Project\credo-ts\[email protected][email protected]\[email protected]\ffi-napi
 ELIFECYCLE  Command failed with exit code 1.

Am I missing something or needs to changed

@genaris
Copy link
Contributor

genaris commented Oct 23, 2024

Maybe this is related to the comment from @btsimonh in nodejs/node#52240 (comment). I'll check as soon as I can get a Windows machine, but in the meantime probably it may work for you if you force node-gyp-build to version 4.8.2, i.e. add it to package.json's resolutions field:

resolutions: {
...
"node-gyp-build": "4.8.2",
...
}

@RinkalBhojani
Copy link
Author

resolutions: { "node-gyp-build": "4.8.2" }

@genaris - I tried this but got the same error.

@btsimonh
Copy link

'"call"' is not recognized as an internal or external command,

see the mods I mention in node-ffi-napi/node-ffi-napi#270 - the one about libffi.gyp.

@RinkalBhojani
Copy link
Author

@genaris @btsimonh - I tried steps given in node-ffi-napi/node-ffi-napi#270 . Still I am getting same error.

I tried these node version v18.19.0 , v20.11.1, v22.11.0.

Could you please help me out with detailed steps to follow?

@btsimonh
Copy link

btsimonh commented Nov 7, 2024

Hi @RinkalBhojani,

pls try these repos:
"ref-napi": "https://github.com/btsimonh/ref-napi.git",
"ref-array-di": "^1.2.2",
"ref-struct-di": "^1.1.1",
"ffi-napi": "https://github.com/btsimonh/node-ffi-napi.git",

for me, this set is working together for node 22.10.0, and should be ok with 18, 20, 22. It's not tested on <= 16, or on odd numbered node.
One test failed for ff-napi, involving a nested 30,000 calls. Once reduced to 15,000, the test is passing.

The changes are a combination of all the resources I could find, plus adapting to use git actions over appveyer. Feel free to use those, or fork them. ffi-napi is a fork of @cclauss version. It include prebuilds for linux, windows, macos x64 macos arm64.
I have yet to heavily test them in real environments, but this will be happening soon, as I do need it to work on all those platforms.
It does install on windows without needing to build, and it did run my initial tests (accessing windows APIs for an updated version of https://github.com/btsimonh/node-windows-root-certs).

br,
Simon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants