Why does create-react-app give "Missing dependencies in package.json" message? - node.js

What's the problem:
I recently started learning reactjs. while creating a new react app, the build fails and only a package.json file is created.
> PS D:\react-projects> npx create-react-app app-name Creating a new
> React app in D:\react-projects\exercount.
>
> Installing packages. This might take a couple of minutes. Installing
> react, react-dom, and react-scripts with cra-template...
>
>
> added 1396 packages, and changed 1 package in 9m 203 packages are
> looking for funding run `npm fund` for details
> Missing dependencies in package.json
What I used:
VS CODE 1.69
Windows 10 Home single language Version 10.0.19044 Build 19044
Node v16.16
NPM v8.13.2
when did i encounter it:
I tried to create my first react app by following the reactjs official tutorial. I opened vs code in administrator mode and ran the following command in the terminal
npx create-react-app myapp
while this worked fine in my friends linux laptop, it failed in my windows one.
All it does is throw a "Missing dependancies in package.json" message and only builds a folder with one package.json file.
What have i tried:
various commands to create the app like - npx, npm create-react-app and create-react-app itself
have run those commands with and without the "-use--npm" flag
forced flushed the npm cache
uninstalled and reinstalled vs code, npm and node
All i found online were a few similar questions with only small number of them with answers. I have tried all of them and nothing worked.If you know what could be causing this, it would be helpful.
Screenshots:
terminal
package.json file

I had the same. The problem was resolved by downgrading npm to version 8.3.0 npm install -g npm#8.3.0

Related

Why npx create-react-app is showing "the project was bootstrapped with an old unsupported version of tools"?

I recently switched to Ubuntu, whenever I create react app it's giving me this note, and the app it's creating is a class component.
ankit#gram:~/Documents/Development/React/react-project$ npx create-react-app my-app
Creating a new React app in /home/ankit/Documents/Development/React/react-project/my-app.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...
added 987 packages in 39s
22 packages are looking for funding
run `npm fund` for details
Success! Created my-app at /home/ankit/Documents/Development/React/react-project/my-app
Inside that directory, you can run several commands:
npm start
Starts the development server.
npm run build
Bundles the app into static files for production.
npm test
Starts the test runner.
npm run eject
Removes this tool and copies build dependencies, configuration files
and scripts into the app directory. If you do this, you can’t go back!
We suggest that you begin by typing:
cd my-app
npm start
Happy hacking!
Note: the project was bootstrapped with an old unsupported version of tools.
Please update to Node >=14 and npm >=6 to get supported tools in new projects.
my node version: v16.14.0
my npm version:8.3.1
I think this was because npx was not installed in my system, when I created a react app by this command create-react-app the app created was fine. I also installed npx using this command npm install -g npx and created a react app and everything was fine. before this make sure you have installed create-react-app in your system if not then install it by using this command
sudo npm install -g create-react-app
I am a new programmer had this issue not long ago I just solved it.
Use sudo apt install nodejs
It will automatically install version 10 for you which doesn't accept React.
Then you try to install NVM package, use it to update your node to a newer version.
You can check me on GitHub bari racha Wuye
I was having the same problem after I had just installed Ubuntu 22.04.
The fix for me was updating node and npm by following these instructions free code camp update node and npm
Specifically, I followed the instructions under the heading "1. Use NPM to Update Your Node Version", to update node and ignored the 2nd and 3rd headings, then followed the instructions under the last heading to update npm
afterwards I restarted my computer, opened the project directory and ran the command
npm i create-react-app#latest
then I ran
npx create-react-app projectname
and it worked as expected

Create-react-app not working - packages looking for funding

I installed node, then I ran npm install create-react-app, then ran npx create-react-app hello-world.
The last command did not go through because of some package funding, whatever that means.
How do I fix this?
I am using windows. Here is how my command prompt looks like:
When you do "npm install create-react-app" you're installing in the current folder a CLI to ease up creating a React template for your projects. Doing "npx create-react-app hello-world" is redundant as you've already downloaded the create-react-app module, if you do not wish to save the CLI software and only create the template then it's a better approach.
Using the "-g" flag will allow you to use the CLI globally to create React projects on your computer ("npm install -g create-react-app" this might require certain permissions) instead of only the specific folder you're on.
Once you're done you must use the command "create-react-app 'your_project_name'" to use create-react-app to create your project. More information here https://reactjs.org/docs/create-a-new-react-app.html#create-react-app, to start the project just head inside the created folder and do "npm start".
Packages looking for funding is exactly what it says, the developers of these modules are looking for funding.
Uninstalling x64 version of node and install x34 version solved my same issue.

unable to create a new project with create-react-app

I've just finished installing create-react-app successfully.
But, when I create a new project like below command, error happens.
Could you please give me a recommandation?
system env.:
- aws lightsail 1vcpu, 0.5G ram / ubuntu 18.04
- nodejs version : 13.9.0
- npm version : 6.13.7
- create-react-app version : 3.4.0
~$ npm create-react-app my-app
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
core-js#2.6.11 postinstall /home/ubuntu/my-app/node_modules/babel-runtime/node_modules/core-js
node -e "try{require('./postinstall')}catch(e){}"
Aborting installation.
npm install --save --save-exact --loglevel error react react-dom react-scripts cra-template has failed.
Deleting generated file... node_modules
Deleting generated file... package.json
Done.
Switch to Yarn
It was a raised issue on github a couple of years back..
it was solved after switching to yarn.
These commands could not solve the issue.
npm cache clean --force
create-react-app my-apps
Switching to Yarn worked!
npm install -g yarn
yarn global add create-react-app
create-react-app my-app
See if this helps!
This error is due to the fact that a dependant module named core-js is trying to run a post-install script. This post-install script spawns a child process and runs a shell script there. For some reason Node sets/assumes a wrong bash path by default. I had to manually change the path by running the following command.
npm config set script-shell $(which sh)
Note: For Windows you might have to setup your own bash.exe by installing something like git-bash and then you could assign the path similarly.
Try this: npm cache clean --force

starting react native app

I'm starting work on React Native, using create-reactive-native-app and Exponent. There is a nice list of open source examples here, some of then are mentioned to use Exponent.
https://github.com/ReactNativeNews/React-Native-Apps
I have few experience with nodejs. I already noticed there are several possible configurations for React Native apps. I usually use npm start to run it, but that don't work on those examples, since since they don't have a start script in package.json.
Take as an example the native-component-list app. How can I execute it after cloning and doing npm install?
Using node v6.11.4 and npm 3.10.10
I also tried using react-native run-android . It works when I create a new project with react-native init Ola2
But not with the downloaded code.
Here are some more details. I did this before: npm install -g react-native-cli
npm install
react-native run-android
Scanning folders for symlinks in xxx/native-component-list/node_modules (25ms)
Android project not found. Maybe run react-native android first?
react-native android
Scanning folders for symlinks in xxx/native-component-list/node_modules (26ms)
Unrecognized command 'android'
Run react-native --help to see list of all available commands
As per this link, you can run the app with command react-native run-android (for android)
I found the problem. I just had never used Expo.io way to create a ReactNative app. I only knew the init and the crna ways. This apps where created with the exp tool.
So,to run it, just do:
npm install exp --global
npm install
exp android
exp start
I didn't work on Expo, I prefer react-native-cli
In your case, your project in developed on Expo.
So you need expo-cli to run the project.
For Expo Cli
npm install -g expo-cli
For CRNA
npm i -g create-react-native-app
Internally CRNA use EXPO, so you can choose any option. After installing the expo-cli npm start command work fine for you.
Or you can eject this project.
You can run npm run eject to get a project very similar to what react-native init would generate. At that point you’ll need Xcode and/or Android Studio just as you would if you started with react-native init , adding libraries with react-native link will work, and you’ll have full control over the native code compilation process.
Hope it will work for you.

React-native removed when use npm install

I don't understand why my npm make that and i'm new with react-native.
Here is the description of my "bug" on Windows 10 :
I can use react-native command for run android or create react-native app like that react-native init TestApp
When i go into my app folder with cd TestApp and i run react-native link or other react-native command everythings work fine.
But if i install a new package like fbsdk with npm like that npm install react-native-fbsdk --save i saw after installation this message :
added 1 package and removed 639 packages in 22.207s
And after that, if i would like use react-native command i have this message :
Command link unrecognized. Make sure that you have run npm install and that you are inside a react-native project.
For this message, i have entered react-native link command.
You know why npm remove all my packages ?
I got the same problem.
However I solved the problem by deleting the package-lock.json and then running npm install.
Check the answer here.
I also noticed recently that npm install doesn't do what I expect, but that may be because I'm newbie.
However yarn install is a good replacement and is working fine for me. I used it to upgrade/downgrade things by directly editing packages.json, and it also solved the npm link problem that I faced.
Edit: downgrading to npm 7 solved all my issues

Resources