Cannot install npm modules

When i run npm install, it returns this error:

npm ERR! code 1
npm ERR! path /home/runner/botwssp/node_modules/sodium
npm ERR! command failed
npm ERR! command sh -c node install.js --preinstall
npm ERR! Static libsodium was not found at /home/runner/botwssp/node_modules/sodium/deps/build/lib/libsodium so compiling libsodium from source.
npm ERR! libtool is required, but wasn't found on this system
npm ERR! make: *** [Makefile:62: libsodium] Error 1
npm ERR! /home/runner/botwssp/node_modules/sodium/install.js:293
npm ERR!             throw new Error(cmdLine + ' exited with code ' + code);
npm ERR!             ^
npm ERR! 
npm ERR! Error: make libsodium exited with code 2
npm ERR!     at ChildProcess.<anonymous> (/home/runner/botwssp/node_modules/sodium/install.js:293:19)
npm ERR!     at ChildProcess.emit (node:events:390:28)
npm ERR!     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/runner/.npm/_logs/2022-09-06T07_25_55_343Z-debug.log

No modules get installed, so i can’t run my repl.

Are you trying to update npm or install it?

If you are trying to update it, try this:
1.Execute this script on the shell to install node (you can choose the version by editing the number 16) and configure npm.

npm init -y && npm i --save-dev node@16 && npm config set prefix=$(pwd)/node_modules/node && export PATH=$(pwd)/node_modules/node/bin:$PATH

2.Create the https://replit.com to execute node from the shell instead of the console.

run = "npm start"

3.Make sure to replace the start script in your package.json file

  "scripts": {

    "start": "node ."
  }

4.(Optional) If you had packages like discord.js or sqlite before, you need to re-install those packages.

npm uninstall discord.js && npm i discord.js

SOURCE: GitHub - Kabin1234/node.js-v16-replit


If you are trying to install npm on a non-npm repl, it probably won’t work.

1 Like

Tried to uninstall sodium. But this different error shows up:

npm ERR! code 1
npm ERR! path /home/runner/botwssp/node_modules/@discordjs/opus
npm ERR! command failed
npm ERR! command sh -c node-pre-gyp install --fallback-to-build
npm ERR! Failed to execute '/nix/store/ra8r42571xvv1m85wanh1ll9mxmp0mwl-nodejs-16.13.2/bin/node /nix/store/ra8r42571xvv1m85wanh1ll9mxmp0mwl-nodejs-16.13.2/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/home/runner/botwssp/node_modules/@discordjs/opus/prebuild/node-v93-napi-v3-linux-x64-glibc-2.33/opus.node --module_name=opus --module_path=/home/runner/botwssp/node_modules/@discordjs/opus/prebuild/node-v93-napi-v3-linux-x64-glibc-2.33 --napi_version=8 --node_abi_napi=napi --napi_build_version=3 --node_napi_label=napi-v3' (1)
npm ERR! node-pre-gyp info it worked if it ends with ok
npm ERR! node-pre-gyp info using node-pre-gyp@0.4.4
npm ERR! node-pre-gyp info using node@16.13.2 | linux | x64
npm ERR! node-pre-gyp info check checked for "/home/runner/botwssp/node_modules/@discordjs/opus/prebuild/node-v93-napi-v3-linux-x64-glibc-2.33/opus.node" (not found)
npm ERR! node-pre-gyp http GET https://github.com/discordjs/opus/releases/download/v0.8.0/opus-v0.8.0-node-v93-napi-v3-linux-x64-glibc-2.33.tar.gz
npm ERR! node-pre-gyp ERR! install response status 404 Not Found on https://github.com/discordjs/opus/releases/download/v0.8.0/opus-v0.8.0-node-v93-napi-v3-linux-x64-glibc-2.33.tar.gz 
npm ERR! node-pre-gyp WARN Pre-built binaries not installable for @discordjs/opus@0.8.0 and node@16.13.2 (node-v93 ABI, glibc) (falling back to source compile with node-gyp) 
npm ERR! node-pre-gyp WARN Hit error response status 404 Not Found on https://github.com/discordjs/opus/releases/download/v0.8.0/opus-v0.8.0-node-v93-napi-v3-linux-x64-glibc-2.33.tar.gz 
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@8.3.0
npm ERR! gyp info using node@16.13.2 | linux | x64
npm ERR! gyp info ok 
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@8.3.0
npm ERR! gyp info using node@16.13.2 | 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 (/nix/store/ra8r42571xvv1m85wanh1ll9mxmp0mwl-nodejs-16.13.2/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:330:47)
npm ERR! gyp ERR! stack     at PythonFinder.runChecks (/nix/store/ra8r42571xvv1m85wanh1ll9mxmp0mwl-nodejs-16.13.2/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:159:21)
npm ERR! gyp ERR! stack     at PythonFinder.<anonymous> (/nix/store/ra8r42571xvv1m85wanh1ll9mxmp0mwl-nodejs-16.13.2/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:202:16)
npm ERR! gyp ERR! stack     at PythonFinder.execFileCallback (/nix/store/ra8r42571xvv1m85wanh1ll9mxmp0mwl-nodejs-16.13.2/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:294:16)
npm ERR! gyp ERR! stack     at exithandler (node:child_process:404:5)
npm ERR! gyp ERR! stack     at ChildProcess.errorhandler (node:child_process:416:5)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:288:12)
npm ERR! gyp ERR! stack     at onErrorNT (node:internal/child_process:477:16)
npm ERR! gyp ERR! stack     at processTicksAndRejections (node:internal/process/task_queues:83:21)
npm ERR! gyp ERR! System Linux 5.15.0-1017-gcp
npm ERR! gyp ERR! command "/nix/store/ra8r42571xvv1m85wanh1ll9mxmp0mwl-nodejs-16.13.2/bin/node" "/nix/store/ra8r42571xvv1m85wanh1ll9mxmp0mwl-nodejs-16.13.2/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/home/runner/botwssp/node_modules/@discordjs/opus/prebuild/node-v93-napi-v3-linux-x64-glibc-2.33/opus.node" "--module_name=opus" "--module_path=/home/runner/botwssp/node_modules/@discordjs/opus/prebuild/node-v93-napi-v3-linux-x64-glibc-2.33" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=3" "--node_napi_label=napi-v3"
npm ERR! gyp ERR! cwd /home/runner/botwssp/node_modules/@discordjs/opus
npm ERR! gyp ERR! node -v v16.13.2
npm ERR! gyp ERR! node-gyp -v v8.3.0
npm ERR! gyp ERR! not ok 
npm ERR! node-pre-gyp ERR! build error 
npm ERR! node-pre-gyp ERR! stack Error: Failed to execute '/nix/store/ra8r42571xvv1m85wanh1ll9mxmp0mwl-nodejs-16.13.2/bin/node /nix/store/ra8r42571xvv1m85wanh1ll9mxmp0mwl-nodejs-16.13.2/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/home/runner/botwssp/node_modules/@discordjs/opus/prebuild/node-v93-napi-v3-linux-x64-glibc-2.33/opus.node --module_name=opus --module_path=/home/runner/botwssp/node_modules/@discordjs/opus/prebuild/node-v93-napi-v3-linux-x64-glibc-2.33 --napi_version=8 --node_abi_napi=napi --napi_build_version=3 --node_napi_label=napi-v3' (1)
npm ERR! node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/home/runner/botwssp/node_modules/@discordjs/node-pre-gyp/lib/util/compile.js:85:20)
npm ERR! node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
npm ERR! node-pre-gyp ERR! stack     at maybeClose (node:internal/child_process:1064:16)
npm ERR! node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
npm ERR! node-pre-gyp ERR! System Linux 5.15.0-1017-gcp
npm ERR! node-pre-gyp ERR! command "/nix/store/ra8r42571xvv1m85wanh1ll9mxmp0mwl-nodejs-16.13.2/bin/node" "/home/runner/botwssp/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
npm ERR! node-pre-gyp ERR! cwd /home/runner/botwssp/node_modules/@discordjs/opus
npm ERR! node-pre-gyp ERR! node -v v16.13.2
npm ERR! node-pre-gyp ERR! node-pre-gyp -v v0.4.4
npm ERR! node-pre-gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/runner/.npm/_logs/2022-09-07T03_22_22_161Z-debug.log

Maybe node-gyp isn’t setup properly