NPM / NodeJS command prompt errors - node.js

I have been trying to look for answers all over and I cannot find any.. Whenever I go to create a react app, (I use visual studio code) I will type in the terminal (I do the NPX lowercase but stack overflow wouldn't let me post if lowercase) NPX create-react-app title and it will open up a new command prompt for a split second then just close.. all i get to see is an error called NPM WARN then it closes.. This happens for almost all NPM commands I do.. Is there any way I can fix this, it is really starting to get annoying.

Since the cause of the error is not clear, first try
npm init react-app my-app
command be sure using npm version 6 or higher. If it doesn't work try
npm install -g create-react-app
then use
npx create-react-app hello-world
command again.
If none of this commands work, you can uninstall npm and other libraries, frameworks related to react then install the last stable versions of them.

Related

react app is successfully created, but npm start throws an error

I installed the latest nodejs 19.2.0 on my windows 11 OS rather than the recommended for most users 18.12.1
npx create-react-app my-first-app works just fine, it creates all the files and folders without any errors, shows happy hacking message as well, recommends to use npm start command. I go inside my-first-app folder, go npm start and I get a module not found error...like this picture
Error Message Screenshot
In youtube tutorials, there is no any error in their pc. npm start runs just as easily as npx create-react-app <anyappname>.
F:\Tutorial & Practice\Frontend development\React Projects\my-first-app. With this path to your project, I can see there is an & symbol in the Tutorial & Practice directory. Sometimes that might cause error. Try renaming the directory without any symbols or even spaces, just to be sure. Then run npm start. And if that still doesn't work delete the node_modules folder and then npm install again and see if that works.
Try this first:
npm install react-scripts
If the error wasn't solved, then try this:
rm -rf node_modules
npm cache clean -f
npm install
npm install react-scripts

I get NPX: command not found whenever I run create-react-app

Whenever I try to create a react app, the CMD always outputs the error below NPX: command not found. I looked at previous GitHub and Stack Overflow questions that were same as mine, however removing and then adding NPX again doesn't work. I also uninstalled node.js and then reinstalled it but that didn't work either! Below is the error and my node version:
enter image description here
Run npm i npm to install node package manager if it was not included in your installation. To make sure the installation was a success run npm -v in the command line.

Npm commands downloaded but not recognize

So I recently update node js pretty much since I was gonna try Angular but now when I try to run any command like create-react-app appname I start to get this.
C:\Users\Mine\AppData\Roaming\npm/node_modules/node/bin/node: line 1:
This: command not found
now I checked my Environmental variables and on top of my Path folder I have
C:\Users\Mine\AppData\Roaming\npm which im pretty sure is the correct
path.
I've tried to change the path to programfiles\node and it did not work as well.
i think you should after update node js uninstall create-react-app
npm uninstall create-react-app
npm uninstall -g create-react-app
npm cache clean --force
at the next
npm install -g create-react-app
Once installation successful, try running
npx create-react-app hello-world
Note
npx on the first line is not a typo — it’s a package runner tool that
comes with npm 5.2+.

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