How to run npm commands like create-react-app offline - javascript

I am working offline without any internet connectivity. I have node JS installed on my system. When I am trying to run the npm create-react-app command it gives me error. Is there any way for me to run npm commands and get react application running offline? Below is the error code I get:
npm ERR! code ENOTFOUND
npm ERR! errcode ENOTFOUND
npm ERR! network request to https://registry.npmjs.org/create-react-app failed,
reason: getaddrinfo ENOTFOUND registry.npmjs.org

and get react application running offline
npm start works offline already. Once you created your application, you should have no problem.
i am trying to run the npm create-react-app command [offline]
Npm is basically a package manager, which downloads dependencies for you, located under /node_modules at your project root.
create-react-app does two things :
Install specific dependencies for React : as a huge framework, React doesn't only require Node.js to run, but also multiple other packages (including React istelf).
Creating a template project with some presets.
If you are working offline and need to create multiple React projects that way, then you'll have no choice but to run the create-react-app command at least once while being online.
However, once you created your first React app, you can just leave the folder untouched : this will give you a fully functional offline copy for your React applications.
When you're back offline, just copy those files to the folder of the React application you want to create (make sure to copy everything, including the node_modules folder). You should then be able to run npm start offline, and build your application.

I believe this is what you are looking for
https://npm.io/package/create-react-app-offline
It helps you create (download) a react project installer, which you can use to create any react JavaScript project offline.

Related

WebStorm not running project, Command `start` unrecognized

I'm very new to React Native, barely two weeks into it. I've installed node.js (ver 10.15.0), I've also installed yarn and downloaded WebStorm.
The problem is that I can't run a simple project created by WebStorm, it throws an error
Command start unrecognized. Make sure that you have run npm install and that you are inside a react-native project.
I've cd into my WebStorm projects folder and run npm install in command prompt countless times but it's still throwing the error. Some online suggestions said I should set my path correctly, but I don't really know how to go about it.
Any help will be appreciated.
You should know The best IDE for react native is VSCode (visual studio code) and don't create project with IDE (you should use commands for create project. just use IDE for manage codes)
use CMD or PowerShell (Recommended) for commands
Create a folder for your project and in the project directory run this commands :
npm install -g expo-cli
expo init Yourprojectname
cd Yourprojectname
npm start
For run android project
react-native run-android
For run android project
react-native run-ios
Also its better to read this tutorial : https://facebook.github.io/react-native/docs/getting-started

React native with expo: ‘react-navigation does not exist in the haste module map’

I’m a beginner working on my first app with react native and expo. I’m having trouble getting the navigation to work. When I run the app, I get the error ‘react-navigation does not exist in the haste module map’. I’ve installed react navigation through the command line and ran install npm to install dependancies.
I also had the same problems few weeks back , please follow the steps below :
Open terminal and navigate to project root directory.
write 'rm -rf node_modules' in the terminal to remove the node modules.
write 'npm install' in order to install the node modules again
write 'cd ios'.
write 'rm -r build' to clear the old build.
come back to the root folder of project again and run the project.
Your code will run smoothly.

React and Bootstrap4 issue when creating application using create-react-app

I am using Windows 10. Follwoing are the two scenarios where I faced problems. I created applications using create-react-app command. I installed create-react-app using command npm i -g create-react-app#1.5.2
Scenario 1
I stopped react server which was running using npm start command. Then I installed bootstrap using npm i bootstarp#4.1.1 and then I tried to run command npm start but rathern than starting the server, it has given an error 'react-scripts' is not recognized as an internal or external command.
The application is working perfactly before I stopped the react server and installed bootstrap.
Steps to recreate the problem:
create-react-app demo
cd demo
npm start (loaded the application in browser with home page)
stopped the server using Ctrl + C (break)
npm i bootstrap#4.1.1
npm start (giving error 'react-scripts' is not recognized as an internal or external command)
Scenario 2
I installed bootstrap in running react server using another command window / visul studio command line using npm i bootstarp#4.1.1 and when I imported bootstrap file in index.js and saved the file. It have given error
./node_modules/style-loader/lib/addStyles.js
Module build failed: Error: ENOENT: no such file or directory, open 'D:\react\demo2\node_modules\style-loader\lib\addStyles.js'
Steps to recreate the problem:
create-react-app demo
cd demo2
npm start (loaded the application in browser with home page)
Open another command window and reached to location demo4 folder
npm i bootstrap#4.1.1
open index.js in src folder and write: import 'bootstrap/dist/css/bootstrap.css';
save the file and error comes.
I've found many topics about this issue:
https://github.com/facebook/create-react-app/issues/1627
https://github.com/facebook/create-react-app/issues/2436
'react-scripts' is not recognized as an internal or external command
I think that it is related to the npm version that you use. It seems that npm doesn't install all the required dependencies.
Try to run npm update in order to update the dependencies. After this, npm start should work fine:
npm update
npm start

Why I can not run my electron application after electron-forge make command?

I have written small Electron application. For building and packaging purposes i have downloaded following node package npm install -g electron-forge
When i run following command electron-forge make following directory is created with contents in it:
Above directory contains file your-app.exe. When i run this file i get following screen:
When i check the appropriate directory, files are presented there:
In development mode, when i try to start application with command electron-forge start application runs wthout any problems.
I can not distribute my application and really need your help: What could be the reason of this issue?

install sails manually on ubuntu server

My Ubuntu server is behind firewall.hence when ever I try to run command to install sails via putty using command npm install sails -g ,I get error Error: connect ECONNREFUSED.
There fore I though if I can download the sails package on to my local and then moving the package manually on firewall server and installing it. I tried looking for some help on web but could not get. Please guide how to proceed
If your computer is not connected to the internet npm will not work.
If you have another computer connected to the internet, you can run the npm commands there and afterwards copy the contents to the other computer. (e.g. via USB stick)
In most cases you should have no problems, even on different operating systems.
Note on global modules: For global modules (e.g. gulp, bower, forever) you will not be able to install into node_modules using this technique. However, you can install them locally by saving them to your package json and running them from their local path.
e.g.
npm install --save forever
./node_modules/forever/bin/forever
Check the files system for the exact path.

Categories

Resources