brain.js
brain.js copied to clipboard
Npm i brain.js || node-gyp error
When installing Brain.js using npm I got this error
Node version 18.18.2 Python version 3.12.0
npm WARN deprecated @npmcli/[email protected]: This functionality has been moved to @npmcli/fs
npm ERR! code 1
npm ERR! path C:\Users\dell\Desktop\Node\GeminiNode\node_modules\gl
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c prebuild-install || node-gyp rebuild
npm ERR! prebuild-install warn install No prebuilt binaries found (target=18.18.2 runtime=node arch=x64 libc= platform=win32)
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | win32 | x64
npm ERR! gyp info find Python using Python version 3.12.2 found at "C:\Users\dell\AppData\Local\Programs\Python\Python312\python.exe"
npm ERR! gyp info find VS using VS2022 (17.9.34622.214) found at:
npm ERR! gyp info find VS "C:\Program Files\Microsoft Visual Studio\2022\Community"
npm ERR! gyp info find VS run with --verbose for detailed information
npm ERR! gyp info spawn C:\Users\dell\AppData\Local\Programs\Python\Python312\python.exe
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args 'C:\Users\dell\Desktop\Node\GeminiNode\node_modules\node-gyp\gyp\gyp_main.py',
npm ERR! gyp info spawn args 'binding.gyp',
npm ERR! gyp info spawn args '-f',
npm ERR! gyp info spawn args 'msvs',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args 'C:\Users\dell\Desktop\Node\GeminiNode\node_modules\gl\build\config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args 'C:\Users\dell\Desktop\Node\GeminiNode\node_modules\node-gyp\addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args 'C:\Users\dell\AppData\Local\node-gyp\Cache\18.18.2\include\node\common.gypi',
npm ERR! gyp info spawn args '-Dlibrary=shared_library',
npm ERR! gyp info spawn args '-Dvisibility=default',
npm ERR! gyp info spawn args '-Dnode_root_dir=C:\Users\dell\AppData\Local\node-gyp\Cache\18.18.2',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=C:\Users\dell\Desktop\Node\GeminiNode\node_modules\node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=C:\\Users\\dell\\AppData\\Local\\node-gyp\\Cache\\18.18.2\\<(target_arch)\\node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=C:\Users\dell\Desktop\Node\GeminiNode\node_modules\gl',
npm ERR! gyp info spawn args '-Dnode_engine=v8',
npm ERR! gyp info spawn args '--depth=.',
npm ERR! gyp info spawn args '--no-parallel',
npm ERR! gyp info spawn args '--generator-output',
npm ERR! gyp info spawn args 'C:\Users\dell\Desktop\Node\GeminiNode\node_modules\gl\build',
npm ERR! gyp info spawn args '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! Traceback (most recent call last):
npm ERR! File "C:\Users\dell\Desktop\Node\GeminiNode\node_modules\node-gyp\gyp\gyp_main.py", line 42, in gyp failed with exit code: 1
npm ERR! gyp ERR! stack at ChildProcess.onCpExit (C:\Users\dell\Desktop\Node\GeminiNode\node_modules\node-gyp\lib\configure.js:325:16)
npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:517:28)
npm ERR! gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:292:12)
npm ERR! gyp ERR! System Windows_NT 10.0.22621
npm ERR! gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\dell\Desktop\Node\GeminiNode\node_modules\node-gyp\bin\node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd C:\Users\dell\Desktop\Node\GeminiNode\node_modules\gl
npm ERR! gyp ERR! node -v v18.18.2
npm ERR! gyp ERR! node-gyp -v v9.4.1
npm ERR! gyp ERR! not ok
npm ERR! A complete log of this run can be found in: C:\Users\dell\AppData\Local\npm-cache_logs\2024-03-11T03_00_33_620Z-debug-0.log
Hey! I find a solution:
Reproduce:
- npm install brain.js
- Same error.
Solution and how I find it:
- Firstly tried to install distutils. I read distutils was not found because it was removed at 3.12.
- Then, I read on my local (Turkish) forum (you can read it clicking by this text) it says it is removed from Python 3.12 and I should use this command instead:
pip install setuptools - I went back to my project folder (main node.js project folder) opened a PowerShell as Administrator and simply pasted command above.
It worked!
Could you possibly add that to the readme?
to solve this, do following:
python3 -m venv .venv
source .venv/bin/activate
pip install setuptools
npm i brain.js
I'm having this problem as well. Please fix it! Running brain.js through a python virtual environment shouldn't be the solution.
From the log...
Python version 3.12.0 npm ERR! gyp info using [email protected]
Python 3.12 REQUIRES node-gyp@10 or greater because it NEEDS setuptools.
I'm getting this error too, and I haven't been able to install brain.js through the suggested methods above (running a python virtual env, installing setuptools, etc).
I also tried installing node-gyp globally so I'm at v10.2.0. Also tried installing node-gyp locally before running npm i brain.js. But it seems when installing brain.js it doesn't make use of either the global or local installed node-gyp.
Does anyone have any suggestions for how to make sure brain.js uses the v10 of node-gyp when running npm i brain.js? Or any other pointers? Thanks for the help, much appreciated!
I also tried installing node-gyp globally so I'm at v10.2.0.
Does your error log say node-gyp v10.2.0?
I also tried installing node-gyp globally so I'm at v10.2.0.
Does your error log say
node-gyp v10.2.0?
No, it seems it keeps using v9 (npm error gyp ERR! node-gyp -v v9.4.1) and I'm not sure how to make it so it does use v10. I tried different things like installing node-gyp globally and locally, but that doesn't seem to make a difference.
Edit or create the node-gyp entry in package.json and/or package-lock.json?
Edit or create the
node-gypentry inpackage.jsonand/orpackage-lock.json?
Nothing to do there sadly, both files have: "node-gyp": "^10.2.0".
I have same issue, ubuntu 24.04 node 20 installed using nvm tried upgrading npm to v11
npm error gyp ERR! node -v v20.17.0 npm error gyp ERR! node-gyp -v v9.4.1
Python >= v3.12 requires node-gyp >= v10.
- https://github.com/nodejs/node-gyp/releases
Python >= v3.12 requires node-gyp >= v10.
- https://github.com/nodejs/node-gyp/releases
We know Python >= 3.12 needs node-gyp >= 10.
node-gyp is called within the gl dependency as a transient dependency from gpu.js. This is why it does not use the correct version installed globally or locally.
The solution for me was to modify the package.json at the root of my project so the child dependencies of brain.js uses the right gl version. I added at the end of my package.json:
"overrides": {
"brain.js": {
"gpu.js": {
"gl": "^8.1.6"
}
}
}
This is a temporary fix and PRs like this one inside the incriminated dependency (gpu.js) are still waiting to be merged.
Python >= v3.12 requires node-gyp >= v10.
- https://github.com/nodejs/node-gyp/releases
We know Python >= 3.12 needs node-gyp >= 10.
node-gypis called within thegldependency as a transient dependency fromgpu.js. This is why it does not use the correct version installed globally or locally.The solution for me was to modify the package.json at the root of my project so the child dependencies of brain.js uses the right gl version. I added at the end of my package.json:
"overrides": { "brain.js": { "gpu.js": { "gl": "^8.1.6" } } }This is a temporary fix and PRs like this one inside the incriminated dependency (gpu.js) are still waiting to be merged.
The pnpm equivilent for this would be
"pnpm": {
"overrides": {
"gl": "^8.1.6"
}
},
Thought I'd add this here just in case.
Hi, I've opened PR about this, updated README. Use distutils.
I'm getting this error too, and I haven't been able to install brain.js through the suggested methods above (running a python virtual env, installing setuptools, etc).
I also tried installing
node-gypglobally so I'm at v10.2.0. Also tried installingnode-gyplocally before runningnpm i brain.js. But it seems when installing brain.js it doesn't make use of either the global or local installed node-gyp.Does anyone have any suggestions for how to make sure
brain.jsuses the v10 of node-gyp when runningnpm i brain.js? Or any other pointers? Thanks for the help, much appreciated!
I've run into this issue as well. What helped in my case was installing some components from the Visual Studio 2022 Installer — not the full IDE, but specifically the C++ build tools (or related development libraries).
Additionally, if brain.js isn't picking up your globally or locally installed node-gyp (v10 in your case), you might want to force an override. One way to do this is by modifying the package.json to explicitly specify the node-gyp version you want during the install process.
Unfortunately, I'm currently on mobile so I can't paste the exact code snippets right now, but I’ll include a detailed explanation and working example in the README and update the PR shortly.
Hope that helps for now!
OK, I've done README update. I hope it merges.