Brain.js on node.js server

Can someone please help me adding brain.js to a node.js server? npm install brain.js doesn`t work. i appreciate help!

Did you accidentally typed the command inside the console instead of the shell?

Also, you may want to type $ npm install --save brain.js into the shell as recommended from their “Getting Started” page.

3 Likes

i have tried that already and got the following error:

npm WARN deprecated @npmcli/move-file@2.0.1: This functionality has been moved to @npmcli/fs
npm notice 
npm notice New major version of npm available! 8.19.2 -> 9.6.1
npm notice Changelog: https://github.com/npm/cli/releases/tag/v9.6.1
npm notice Run npm install -g npm@9.6.1 to update!
npm notice 
npm ERR! code 1
npm ERR! path /home/runner/test-6/node_modules/gl
npm ERR! command failed
npm ERR! command sh -c -- prebuild-install || node-gyp rebuild
npm ERR! prebuild-install warn install No prebuilt binaries found (target=18.12.1 runtime=node arch=x64 libc= platform=linux)
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@9.3.1
npm ERR! gyp info using node@18.12.1 | linux | x64
npm ERR! gyp ERR! find Python 
npm ERR! gyp ERR! find Python Python is not set from command line or npm configuration
npm ERR! gyp ERR! find Python Python is not set from environment variable PYTHON
npm ERR! gyp ERR! find Python checking if "python3" can be used
npm ERR! gyp ERR! find Python - "python3" is not in PATH or produced an error
npm ERR! gyp ERR! find Python checking if "python" can be used
npm ERR! gyp ERR! find Python - "python" is not in PATH or produced an error
npm ERR! gyp ERR! find Python 
npm ERR! gyp ERR! find Python **********************************************************
npm ERR! gyp ERR! find Python You need to install the latest version of Python.
npm ERR! gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
npm ERR! gyp ERR! find Python you can try one of the following options:
npm ERR! gyp ERR! find Python - Use the switch --python="/path/to/pythonexecutable"
npm ERR! gyp ERR! find Python   (accepted by both node-gyp and npm)
npm ERR! gyp ERR! find Python - Set the environment variable PYTHON
npm ERR! gyp ERR! find Python - Set the npm configuration variable python:
npm ERR! gyp ERR! find Python   npm config set python "/path/to/pythonexecutable"
npm ERR! gyp ERR! find Python For more information consult the documentation at:
npm ERR! gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
npm ERR! gyp ERR! find Python **********************************************************
npm ERR! gyp ERR! find Python 
npm ERR! gyp ERR! configure error 
npm ERR! gyp ERR! stack Error: Could not find any Python installation to use
npm ERR! gyp ERR! stack     at PythonFinder.fail (/home/runner/test-6/node_modules/node-gyp/lib/find-python.js:330:47)
npm ERR! gyp ERR! stack     at PythonFinder.runChecks (/home/runner/test-6/node_modules/node-gyp/lib/find-python.js:159:21)
npm ERR! gyp ERR! stack     at PythonFinder.<anonymous> (/home/runner/test-6/node_modules/node-gyp/lib/find-python.js:202:16)
npm ERR! gyp ERR! stack     at PythonFinder.execFileCallback (/home/runner/test-6/node_modules/node-gyp/lib/find-python.js:294:16)
npm ERR! gyp ERR! stack     at exithandler (node:child_process:420:5)
npm ERR! gyp ERR! stack     at ChildProcess.errorhandler (node:child_process:432:5)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
npm ERR! gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:289:12)
npm ERR! gyp ERR! stack     at onErrorNT (node:internal/child_process:476:16)
npm ERR! gyp ERR! stack     at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
npm ERR! gyp ERR! System Linux 5.15.0-1030-gcp
npm ERR! gyp ERR! command "/nix/store/dj805sw07vvpbxx39c8g67x8qddg0ikw-nodejs-18.12.1/bin/node" "/home/runner/test-6/node_modules/.bin/node-gyp" "rebuild"
npm ERR! gyp ERR! cwd /home/runner/test-6/node_modules/gl
npm ERR! gyp ERR! node -v v18.12.1
npm ERR! gyp ERR! node-gyp -v v9.3.1
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/runner/.npm/_logs/2023-03-12T17_24_07_577Z-debug-0.log

Add Python via Nix: in shell:

sed -i 's/];/  pkgs.python311\n  &/' replit.nix
1 Like
npm WARN deprecated @npmcli/move-file@2.0.1: This functionality has been moved to @npmcli/fs
npm notice 
npm notice New major version of npm available! 8.19.2 -> 9.6.1
npm notice Changelog: https://github.com/npm/cli/releases/tag/v9.6.1
npm notice Run npm install -g npm@9.6.1 to update!
npm notice 
npm ERR! code 1
npm ERR! path /home/runner/test-6/node_modules/gl
npm ERR! command failed
npm ERR! command sh -c -- prebuild-install || node-gyp rebuild
npm ERR! prebuild-install warn install No prebuilt binaries found (target=18.12.1 runtime=node arch=x64 libc= platform=linux)
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@9.3.1
npm ERR! gyp info using node@18.12.1 | linux | x64
npm ERR! gyp info find Python using Python version 3.11.0 found at "/nix/store/xl5l0wnjhwbyjl7mhbn2d8fy4rs02lbp-python3-3.11.0/bin/python3"
npm ERR! gyp http GET https://nodejs.org/download/release/v18.12.1/node-v18.12.1-headers.tar.gz
npm ERR! gyp http 200 https://nodejs.org/download/release/v18.12.1/node-v18.12.1-headers.tar.gz
npm ERR! gyp http GET https://nodejs.org/download/release/v18.12.1/SHASUMS256.txt
npm ERR! gyp http 200 https://nodejs.org/download/release/v18.12.1/SHASUMS256.txt
npm ERR! gyp info spawn /nix/store/xl5l0wnjhwbyjl7mhbn2d8fy4rs02lbp-python3-3.11.0/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/home/runner/test-6/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   'make',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/home/runner/test-6/node_modules/gl/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/home/runner/test-6/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/home/runner/.cache/node-gyp/18.12.1/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=/home/runner/.cache/node-gyp/18.12.1',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/home/runner/test-6/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/home/runner/.cache/node-gyp/18.12.1/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/home/runner/test-6/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   'build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! /nix/store/dsd5gz46hdbdk2rfdimqddhq6m8m8fqs-bash-5.1-p16/bin/sh: line 1: pkg-config: command not found
npm ERR! gyp: Call to 'pkg-config --libs-only-L --libs-only-other x11 xi xext' returned exit status 127 while in angle/src/angle.gyp. while loading dependencies of binding.gyp while trying to load binding.gyp
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 (/home/runner/test-6/node_modules/node-gyp/lib/configure.js:325:16)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
npm ERR! gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:291:12)
npm ERR! gyp ERR! System Linux 5.15.0-1030-gcp
npm ERR! gyp ERR! command "/nix/store/dj805sw07vvpbxx39c8g67x8qddg0ikw-nodejs-18.12.1/bin/node" "/home/runner/test-6/node_modules/.bin/node-gyp" "rebuild"
npm ERR! gyp ERR! cwd /home/runner/test-6/node_modules/gl
npm ERR! gyp ERR! node -v v18.12.1
npm ERR! gyp ERR! node-gyp -v v9.3.1
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/runner/.npm/_logs/2023-03-12T17_35_04_555Z-debug-0.log

same for pkgconfig

sed -i 's/];/  pkgs.pkg-config\n  &/' replit.nix
1 Like
Error: Cannot find module 'gpu.js'
Require stack:
- /home/runner/test-6/node_modules/brain.js/dist/index.js
- /home/runner/test-6/index.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
    at Module._load (node:internal/modules/cjs/loader:841:27)
    at Module.require (node:internal/modules/cjs/loader:1061:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.<anonymous> (/home/runner/test-6/node_modules/brain.js/dist/index.js:5:14)
    at Module._compile (node:internal/modules/cjs/loader:1159:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
    at Module.load (node:internal/modules/cjs/loader:1037:32)
    at Module._load (node:internal/modules/cjs/loader:878:12)

i have got this error now

Just install the modules like how you did with brain.js

Its still not working. Can you please make a working version? I could just fork it then.

Greetings, Spllit

Try using Brain.js V1.6.1 with the following command:

npm install brain.js@1.6.1

If it does not work, reply to this message and I’ll send you a forkable repl with Brain.js installed.

5 Likes

https://replit.com/@UMARismyname/Brainjs

3 Likes

Thanks! It worked.
Greetings, Spllit

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.