How to fix package.json to properly run my react app? - npm

I'm having trouble launching my React App. I get the same message:
"npm ERR! missing script: start"
but I do have start in my package.json.

Related

Expo issue when running app for the first time

I'm using Expo CLI to create my first react-native app, I installed Expo globally and npm modules too, but when I start my app using "expo start" or "npm start" the page give me this error "Expo Developer Tools is disconnected from Expo CLI. Use the expo start command to start the CLI again."
I tryed to install watchman but I can't install it, what can I do? I have Mac OS.
Try re-installing the Expo CLI, by running:
npm uninstall -g expo-cli && npm install -g expo-cli

In React native yarn start is not working in cmd

I am new in react native so help me starting with it,
when i type yarn start in cmd it shows me that error
Error: spawn cmd ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:268:19)
at onErrorNT (internal/child_process.js:468:16)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
I have no idea where i have a problem.
In react native, you have to run the app either on android or ios by running these commands.
react-native run-android
OR
react-native run-ios

Why does react-native uinstall after running react-native command to install a package?

I installed react-native globally and confirmed installation on Windows 10. Then I ran react-native command in PowerShell to install materials-kit and vector-icons. The installation of these packages failed and the directory is no longer considered a react-native project directory. I have to reinstall react-native as a result.
How can I install materials-kit and vector-icons without causing the system to uninstall react-native?
Steps Taken
I ran the below code in PowerShell. Please Note: I also used MS Visual Code and the Terminal in MS Studio Code.
Input
npm install -g react-native-cli
react-native -version
Output
react-native-cli: 2.0.1
react-native: 0.59.5
Additional Input
npm install --save react-native-material-kit react-native-vector-icons
react-native -version
Additional Ouput
react-native-cli: 2.0.1
react-native: n/a - not inside a React Native project directory
I was expecting these two react-native packages to be installed. Did not happen.
Extra Information: Error Code Snippet
...
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall rename
...
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
you have to create a project with the react-native-cli then add your required packages there.
so the steps should be like this:
install the cli tool as you've done it very well.
npm install -g react-native-cli
create a project (you need to provide a name for it).
react-native init *<project_name>*
change your current directory to the created project
cd *<project_name>*
install your favorite packages.
npm install --save react-native-material-kit react-native-vector-icons
run the react-native packager for your target platform (ios or android)
react-native run-ios
or
`react-native run-android`
happy coding!
I solved the program by starting again with no active react-native directory.
1. decided to use Expo to expedite the react-native application set-up process
npm install expo-cli --global
2. initialised new project && changed directory
expo init cra
cd cra
3. installed the react-native material-kit and vector-icons packages individually using yarn instead of npm
yarn add react-native-material-kit
yarn add react-native-vector-icons
4.confirmed installation
Input
react-native -version
Output
react-native-cli: 2.0.1
react-native: 0.57.1

npm ERR! missing script: android

I get several npm ERR! when trying to run : D:\React Native\cleanProject>npm run android
npm ERR! missing script: android
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\User\AppData\Roaming\npm-cache_logs\2019-03-26T08_39_44_164Z-debug.log
npm i
D:\React Native\cleanProject>npm run android
npm ERR! missing script: android
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\User\AppData\Roaming\npm-cache_logs\2019-03-26T08_39_44_164Z-debug.log
The command that you are trying to run is doesn't exist. Please try to run with this given below command.
react-native run-android
I think you need to run the following command for installing 'react-native' project to your Node JS first.
npm install react-native
After that, also make sure an emulator is started or cell phone is connected with developer mode.
And then retry by running
react-native run-android
to see if you can build and run the your application successfully.
check if your environment variable set properly.
In your PATH Variable:
C:\Users[Username]\AppData\Local\Android\Sdk\platform-tools C:\Users[Username]\AppData\Local\Android\Sdk\tools
C:\Program Files\nodejs
In your system Variable
ANDROID_HOME C:\Users[Username]\AppData\Local\Android\Sdk
JAVA_HOME C:\Program Files\Java\jdk1.8.0_191
Hope it works...
Follow this command, it works for me
npx react-native run-android
make sure you are in the root directory of your app before using react-native run-android
1- open your project and make sure you see the android rectory
2- in the address bar at the top type cmd and a new cmd will open at that location
3- type react-native run-android
I hope it helps

How can i run a demo React Native Code on Phone

Im totally new to React Native and just learned to setup the necessary environments and follow these steps;
Install Node.js
Download Expo client at mobile device
npm install -g create-react-native-app
cd to my desired directory
create-react-native-app some_app_name
cd to my app folder containing default app.js
npm start
basic / empty app will be loaded on my phone and code can be opened using editor of choice.
Now i've downloaded some demo simple apps from github and udemy (with full source code)
I tried to extract the files and cd to the folder and execute "npm start"
However, there is always this error
react-native-scripts: command not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! demo_app#0.1.0 start: react-native-scripts start
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the demo_app#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
May i know what is missing? How do i get this right?
The command to run a react-native app is react-native run-android for android devices and react-native run-ios for ios devices. Are you sure that you are running these commands to start the app?
Seems like this might be a duplicate of:
sh: react-scripts: command not found after running npm start