What is needed to create react app offline? - javascript

I am working offline without any internet connectivity. I have Node.js installed on my system. When I try to run the npm create-react-app command it gives me an error. Is there any way for me to run npm commands and get react application running offline? If I create react app on another computer (with an internet connection) and took that in my PC via pen drive, will it work? Below is the error code I get:
npm ERR! errcode ENOTFOUND
npm ERR! network request to https://registry.npmjs.org/create-react-app failed,
reason: getaddrinfo ENOTFOUND registry.npmjs.org

In your question, I saw that you are using the command npm create-react-app. I think, it should be npx create-react-app.
NPM by itself does not simply run any package. it doesn't run any package in a matter of fact.
npx will check whether exists in $PATH, or in the local project binaries, and execute it
And if you run the create react app function on another computer (with internet connection) and take that to your PC via pen drive, it will work.

Related

Installing Firebase tools: Stuck at downloading Chromium

I am trying to run in the terminal of the vs code since I plan to host this online already:
npm install -g firebase-tools
But it is stuck here:
This is my package.json
The version of node.js installed in my computer is:
v14.15.4
Can you try the command with --loglevel verbose
This will show the log information, may point to the issue.
The install generally is pretty smooth, without any problems.

React Installation problem npx-create-react-app not working properly

This is the error that Im facing every-time i do npx create-react-app app-name.
At first It was all good everything was working perfectly but all of a sudden it's been a few days since Im facing this error and i cant seem to solve it.
hassan_xiddiqui#Kratos:~/React$ npx create-react-app starter_1
Need to install the following packages:
create-react-app
Ok to proceed? (y) y
Creating a new React app in /home/hassan_xiddiqui/React/starter_1.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
npm ERR! code ECONNRESET
npm ERR! errno ECONNRESET
npm ERR! network Invalid response body while trying to fetch https://registry.npmjs.org/eslint-plugin-jsx-a11y: aborted
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'
npm ERR! A complete log of this run can be found in:
npm ERR! /home/hassan_xiddiqui/.npm/_logs/2021-04-03T12_14_14_243Z-debug.log
Aborting installation.
npm install --save --save-exact --loglevel error react react-dom react-scripts cra-template has failed.
Deleting generated file... package.json
Deleting starter_1/ from /home/hassan_xiddiqui/React
Done.
The error is very clear in the message you're receiving:
This is a problem related to network connectivity.
In most cases you are behind a proxy or have bad network settings.
If you are behind a proxy, please make sure that the
'proxy' config is set properly. See: 'npm help config'
If you're using a VPS, disable it. Try checking your DNS settings, maybe change them to Google's.
Also, try to install anything from NPM to confirm this is an issue with your connection. npm install -g create-react-app. If this (or any other package) succeeds, it may be other issue.
Consider as well it could be an issue with npx on your machine. Try installing it using create-react-app directly instead by first installing it globally (like I showed above)
It's more of an network error you can check the config or try to flush your dns or something. Maybe try some other network if possible
Try to install npm again using: npm install
Also check what node version you're using: node --v
Then, run the command again: npx create-react-app app_name

How to run Visual Studio Code locally with localhost?

I need help running localhost to connect with vs code. I am trying to open a phaser 3 game I built.
I have tried npm install -g
I keep getting permissions denied.
Could you try with sudo command(if you are using mac or ubuntu)
sudo npm install -g
If you are using windows, then open the terminal with admin rights. (Run as administrator)

Unable to run Electron Quick Start in WSL

Hi I'm running Ubuntu 16.04.3 LTS on Windows Subsystem Linux. I'm trying to run the Quick Start first app as listed in this section here https://electronjs.org/docs/tutorial/first-app however, I keep getting the same error no matter if I clone the repository, write it myself, or delete and reinstall the Electron module.
> electron .
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! first-electron#1.0.0 start: `electron .`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the first-electron#1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
For reference I'm running
Node: 9.11.1
NPM: 5.8.0
Electron needs to open a chrome browser window. So, when you run it from WSL using a node.js that was installed in WSL, I guess it would try to start the chromium browser for Ubuntu, which will not work out of the box, because:
Microsoft doesn't support graphical programs on WSL. Bash on WSL is intended for running command-line programs that developers might need, but it's possible to run graphical Linux desktop programs on Windows using the Bash shell. To be more precise, you'll be able to display graphical programs running in WSL on a Windows 10 desktop by using an X server which runs on Windows 10.
https://virtualizationreview.com/articles/2017/02/08/graphical-programs-on-windows-subsystem-on-linux.aspx
I found the easiest way is to install electron on Windows then start it from WSL.
Steps:
Make sure you have Node.js & npm installed on your Windows machine (you can remove them afterwards)
Open cmd.exe, move to your project directory and run npm install electron --save-dev.
This will install the Windows version of the prebuilt Electron binary instead of the Linux one, which would occur if you try to install from WSL. (This is the actual trick)
Enter Bash on Ubuntu on Windows, move to your project directory then run ./node_modules/.bin/electron (or use an npm script) to launch your Electron app
Though, I'm not sure this is very convenient, it seems to work well.
I hope this will help people encoutering the same issue in the future!
Ref: https://github.com/electron-userland/electron-prebuilt/issues/260
run a X-server app in windows, then export DISPLAY , run the npm start.

Can`t make gRPC work with Electron.js

I`m making an Electron app that should connect by grpc to remote host and call some functions from there.
But I keep getting the following error:
Uncaught Error: A dynamic link library (DLL) initialization routine failed.
\?\D:\Projects\demo-app\node_modules\grpc\src\node\extension_binary\grpc_node.node
I tried to:
establish grpc connection from main and from renderer processes of Electron
install dependencies as npm install --unsafe-perm
but nothing works.
Error
The gRPC package is distributed with precompiled binaries for Electron, including on Windows, but you have to specify that you're using Electron when you do the installation. The following should work:
npm install grpc --runtime=electron --target=<electron version>
If you're using a native module, you'll need to rebuild them against your current electron node version.
There is a package called electron-rebuild that will do this for you. Basic instructions:
npm install --save-dev electron-rebuild
Then, whenever you install a new npm package, rerun electron-rebuild:
./node_modules/.bin/electron-rebuild
Or if you're on Windows:
.\node_modules\.bin\electron-rebuild.cmd

Categories

Resources