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

Npm i brain.js || node-gyp error #930

Open
Ramank200 opened this issue Mar 11, 2024 · 10 comments
Open

Npm i brain.js || node-gyp error #930

Ramank200 opened this issue Mar 11, 2024 · 10 comments
Labels

Comments

@Ramank200
Copy link

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
npm ERR! import gyp # noqa: E402
npm ERR! ^^^^^^^^^^
npm ERR! File "C:\Users\dell\Desktop\Node\GeminiNode\node_modules\node-gyp\gyp\pylib\gyp_init_.py", line 9, in
npm ERR! import gyp.input
npm ERR! File "C:\Users\dell\Desktop\Node\GeminiNode\node_modules\node-gyp\gyp\pylib\gyp\input.py", line 19, in
npm ERR! from distutils.version import StrictVersion
npm ERR! ModuleNotFoundError: No module named 'distutils'
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: 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

@Ramank200 Ramank200 added the bug label Mar 11, 2024
@atailh4n
Copy link

atailh4n commented Jun 7, 2024

Hey! I find a solution:

Reproduce:

  1. npm install brain.js
  2. 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!

@robertleeplummerjr
Copy link
Contributor

Could you possibly add that to the readme?

@DasRed
Copy link

DasRed commented Jul 22, 2024

to solve this, do following:

python3 -m venv .venv             
source .venv/bin/activate
pip install setuptools
npm i brain.js

@AdonisAIOfficial
Copy link

I'm having this problem as well. Please fix it! Running brain.js through a python virtual environment shouldn't be the solution.

@cclauss
Copy link
Contributor

cclauss commented Oct 16, 2024

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.

@tmhglnd
Copy link

tmhglnd commented Oct 19, 2024

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!

@cclauss
Copy link
Contributor

cclauss commented Oct 19, 2024

I also tried installing node-gyp globally so I'm at v10.2.0.

Does your error log say node-gyp v10.2.0?

@tmhglnd
Copy link

tmhglnd commented Oct 19, 2024

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.

@cclauss
Copy link
Contributor

cclauss commented Oct 19, 2024

Edit or create the node-gyp entry in package.json and/or package-lock.json?

@tmhglnd
Copy link

tmhglnd commented Oct 19, 2024

Edit or create the node-gyp entry in package.json and/or package-lock.json?

Nothing to do there sadly, both files have: "node-gyp": "^10.2.0".

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

No branches or pull requests

7 participants