Unable to install webtorrent-hybrid - node-pre-gyp: command not found - node.js

I'm trying to install webtorrent-hybrid to build an electron p2p app. I'm using vue ui because the app will use vue to manage front-end stuff and I've successfully created a new project that use vue-cli-plugin-electron-builder rc-6, Vue 3 and node v15.4.0. The Electron version installed by the vue cli plugin is 11.0. Anyway When I try to install webtorrent-hybrid I always get this error in terminal
npm ERR! code 1
npm ERR! path /Users/dev/Sites/wtorrent-electron/node_modules/wrtc
npm ERR! command failed
npm ERR! command sh -c node scripts/download-prebuilt.js
npm ERR! /bin/sh: node-pre-gyp: command not found
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/dev/.npm/_logs/2021-03-26T16_40_51_717Z-debug.log
command failed: npm install --loglevel error webtorrent-hybrid --legacy-peer-deps
Is there a way to fix it so I can install the library? If isn't possible to solve the problem, is there any alternative to use webtorrent inside an electron app?

Try Node 14 (current lts) which has better prebuilts and if not, using the command npm install --unsafe-perm=true should do the trick.

I run first this
npm i -g #mapbox/node-pre-gyp
And after this I ran
npm i webtorrent-hybrid
and it worked

Related

Installing dependencies with npm-peer-dependencies

I am trying to install the required node_modules for a small project running Angular 11 using npm install
My goal is get the project to work locally after downloading it from GitHub. I have already installed the latest version of the Angular CLI.
After running the install command I tried npm start.
I was expecting that after running the install and start command to be able to run the project locally.
However the actual result I get after running the install command is the following list of errors:
> ng serve
An unhandled exception occurred: Cannot find module '#angular/compiler'
Require stack:
\node_modules\#angular\compiler-cli\index.js
\node_modules\#ngtools\webpack\src\angular_compiler_plugin.js
\node_modules\#ngtools\webpack\src\index.js
\node_modules\#angular-devkit\build-angular\src\webpack\configs\typescript.js
\node_modules\#angular-devkit\build-angular\src\webpack\configs\index.js
\node_modules\#angular-devkit\build-angular\src\browser\index.js
\node_modules\#angular-devkit\build-angular\src\dev-server\index.js
\node_modules\#angular-devkit\architect\node\node-modules-architect-host.js
\node_modules\#angular-devkit\architect\node\index.js
\node_modules\#angular\cli\models\architect-command.js
\node_modules\#angular\cli\commands\serve-impl.js
\node_modules\#angular-devkit\schematics\tools\export-ref.js
\node_modules\#angular-devkit\schematics\tools\index.js
\node_modules\#angular\cli\utilities\json-schema.js
\node_modules\#angular\cli\models\command-runner.js
\node_modules\#angular\cli\lib\cli\index.js
\node_modules\#angular\cli\lib\init.js
\node_modules\#angular\cli\bin\ng
See "angular-errors.log" for further details.
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file C:\WINDOWS\system32\cmd.exe
npm ERR! errno ENOENT
npm ERR! `ng serve`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the #0.0.16 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
The problem is that this Angular project also has peer dependencies. I installed npm-install-peers package but it seems that simply running npm install afterwards will not install the required peer dependencies.
What should I do next to get this Angular project installed locally ?
The issue you are facing is likely because angular cli or npm-peer-dependencies are not installed globally on your machine.
The steps that you should take are to make sure of them are globally installed.
To install packages globally you need run npm install -g <package_name>
npm docs link
In your case for angular cli you should run
npm i -g #angular/cli#11.2.15 and npm install -g npm-peer-dependencies.
Then run npm start.

Created Electron app but when I run "npm start" it doesn't start the app

I'm trying to install electron so I can create an app. I have the latest npm installed (8.3.1) and when I run "npm install electron --save-dev" I keep getting this error:
PS C:\Users\archa\HCIRA\blah> npm install electron --save-dev
npm ERR! code 1
npm ERR! path C:\Users\archa\HCIRA\blah\node_modules\electron
npm ERR! command failed
npm ERR! command bash -c node install.js
npm ERR! Windows Subsystem for Linux has no installed distributions.
npm ERR! Distributions can be installed by visiting the Microsoft Store:
npm ERR! https://aka.ms/wslstore
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\archa\AppData\Local\npm-cache\_logs\2022-01-
15T14_42_33_350Z-debug-0.log
"blah" is the folder where all my code is (index.js, package.json etc.). I've tried using the resources I found on Stack and GitHub but none of them have worked out for me at all. I was even told that the "--save-dev" suffix would be useful for installing Electron on Windows but it didn't work.

Can't install package with NPM behind proxy

I'm trying to install Electron in NPM , using this command:
npm install --save-dev electron
But I always got :
npm ERR! command failed
npm ERR! command sh -c node install.js
npm ERR! RequestError: read ECONNRESET
I configured the file .npmrc with following configs:
registry=http://registry.npmjs.org/
strict-ssl=false
proxy=http://mycompany.proxy:8080/
https-proxy=http://mycompany.proxy:8080/
But didn't resolve. I tried follow this guide: https://www.electronjs.org/docs/latest/tutorial/installation#proxies. So added ELECTRON_GET_USE_PROXY but same error.
I'm running npm within a MacOS BigSur.

npm ERR! cb.apply is not a function (Elementary OS)

I am very new to react native and nodejs . Today I installed nodejs on my Elementary Os and installed npm and npx. Now when I try to run npx create-react-app myApp i am getting the following error :
npm ERR! cb.apply is not a function npm ERR! A complete log of this
run can be found in: npm ERR!
/home/user/.npm/_logs/2021-04-29T08_55_29_599Z-debug.log Install for [
'create-react-project#latest' ] failed with code 1
I found some answers on stack overflow but they didn't solve this. Any help would be much appreciated.
npx version:10.2.2
npm version: 7.10.0
node version :16.0.0
I finally solved the error and i am going to keep this thread open if anyone else faces the same problem.
By default, npm installs packages in the local node_modules/ directory. Since npm i npm is shorthand for npm install npm, it will install the latest version of npm locally.
However, when run npm in a shell, the shell picks up the npm in your $PATH, which is probably the global installation.
To update the global installation of npm, run:
npm install --global npm

Cypress installation failed

I installed nodejs and npm on windows 10. Than I tried to install cypress via npm install cypress --save-dev and get the following Error:
> node index.js --exec install
The command "node" is either misspelled or
could not be found.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! cypress#3.8.2 postinstall: `node index.js --exec install`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the cypress#3.8.2 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\U\AppData\Roaming\npm-cache\_logs\2020-01-21T11_05_01_566Z-debug.log
After this I added the path %USERPROFILE%\AppData\Local\Temp to my system environment variables. But I get this error messages again. How can I fix this problem?
try the following steps :
install git on your machine and config it as global.
delete old package.js then re-init new package.
try again cypress install command
Try this instead by installing the previous version but Explicitly: npm install cypress#8.1.0 --save-dev
Download it in the any directory its a hack to download, if your proxy is properly configured and internet speed is good. it will download while doing npm install
wget https://cdn.cypress.io/desktop/7.6.0/win32-x64/cypress.zip
Provide the zip location
CYPRESS_INSTALL_BINARY=~/Downloads/cypress.zip npm install cypress
Remember to actually run the npm command inside your folder with the package.json.
Delete the package.json.
Again re build the package by npm init.
Install Cypress again by using npm install cypress --save-dev.

Resources