Facing error while installing npm in react - node.js

I want to make a react project but when I execute npx create-react-app, it doesn't respond. Can anyone tell me what the issue I am facing here is? Screenshot.

make an empty folder then drag it over VSC, and type in terminal: npx create-react-app . (dot means in the current folder) also make sure u have node installed, type: node -v (to check what version u have)

From the official ReactJS Docs:
You’ll need to have Node >= 14.0.0 and npm >= 5.6 on your machine. To create a project, run:
npx create-react-app my-app
cd my-app
npm start
In the screenshot you provided, you indeed ran the command; but, it doesn’t show that you checked that the directory, visual, was created within your working directory, New folder. In addition, no error message was output; so as it stands, we know the npx command exists; and can only assume that, the command executed without error.
When using create-react-app:
A new directory will be created in the working directory (in your case, New folder) you run the command within.
This new directory will have the name of the argument you provided to create-react-app (in your case, visual).
So your directory structure you look like this:
New folder/
└─ visual/
The issue I see is that, the general output normally seen when running create-react-app (as shown here) did not appear in your screenshot; however, I’ve never ran it from MS PowerShell, as you appear to be. So you’ll want to check:
That you’re not overthinking this, and ensure that the, my-app, folder really wasn’t created;
And that your NodeJS version is either 14.0.0 or higher:
node -v
And that create-react-app was not installed globally:
To check this, run:
npm list -g
If you see create-react-app in the list, run:
npm uninstall -g create-react-app
npm install create-react-app
Or that running it from cmd (or cygwin) instead of powershell is maybe the better option.

Related

ANY ng command will fail when trying angular due to invalid character error in ng file

The \AppData\Roaming\npm\node_modules#angular\cli\bin\ng.js file cannot be opened and it gives an error whenever I try to use an ng command anywhere, be it in an angular project or elsewhere.
The error is as follows:
Script: (my username)\AppData\Roaming\npm\node_modules#angular\cli\bin\ng.js
Line: 1
Character: 1
Error: Invalid Character
Code: 800A03F6
Source: Compilationerror Microsoft Jscript
What I have tried:
using ng commands in different project -- same error
reinstall npm, angular, removing the node modules in all combinations
Setting the angular path in the environment variables
What happened before:
ng command was missing possibly due to stuff related to python install. This error is replaced with my current problem when reinstall is done.
I have reinstalled everything to the fullest extent but the problem keeps persisting.
I can use my angular project by running 'npm run ng serve' and that weirdly works.
Does anyone have ANY idea what might cause this problem
EDIT:
I have somehow managed to resolve the problem but I have no clear answer what was the cause of it all. I did reinstall nodeJS on my computer which MIGHT have been broken during another project.
Remove the user environment variable
C:\Users\AppData\Roaming\npm\node_modules#angular\cli\bin
It worked for me after losing a day of life looking for a solution
In my case this error occured because of permissions on windows. Try to run cmd as Administrator.
Deleting and reinstalling node.js did not fix it. The issues started when I installed latest CLI which is 13.
I removed npm folder from C:\Users\username\AppData\Roaming then I installed the previous version
npm install -g #angular/cli#12.0.0
I do not get the error anymore.
What worked for me is setting this path:
set path=%PATH%;C:\Users{username}\AppData\Roaming\npm
Firstly you need to set the path of npm
$ npm config get prefix
make sure path matches with npm config get prefix
export PATH=/usr/local/share/npm/bin:$PATH
in windows you can set by advance system settings -> Environment variable -> set path.
Restart you system then do this -
$ npm install -g #angular/cli#latest
get package version
$ ng version
create workspace
$ ng new my-project
run the application
$ cd my-project
$ ng serve

NPX create-react-app terminal tells me node is not installed but it is

At the risk of looking like a complete idiot, why doesn't npx create-react-app my-app work for me? I have node and npm installed and updated, both in my path (as far as I can tell). When I type node -v and npm -v it works perfectly fine, gives me the version numbers, and I can use them just fine, but I get '"node"' is not recognized as an internal or external command,
operable program or batch file. from the terminal when I try the create-react-app statement. Everything else I've found on the internet tries to say by adding it to the path it will work, but I must be missing something.
By the way, I'm using windows with GitBash.
Thanks in advance.
First step:
npm cache clean --force
Second step:
npm install -g create-react-app
Third step:
Once installation successful, try running
npx create-react-app my-app

why i am not able to install all the dependencies in react?

enter image description hereI tried running all the commands including npx create-react-app npm create-react-app npm install npm clear cache --f everything.
still i am not able to install all the dependencies in my package json
The fact that a package is asking for funding should not affect your installation. It simply means that the author(s) is/are looking for financial support to continue their work.
To create a new installation and avoid possible issues - go to a new directory and type the following on your command prompt:-
npx create-react-app todo1
Then, you need to navigate to the folder of your newly created app, "todo1" by running the following:
cd todo1
Finally to run the app, type the following:
npm start
First I want to say your commands are not clear and those are not separated. I assume you need to create react app with npm package manager.
If you run npx create-react-app todo1 you will create a react app with yarn dependency manager.
If you need to use npm dependency manager use the following command
npx create-react-app todo1 --use-npm
Then check the root directory. it should have the package.json file with necessary initial dependencies.

npm and other modules commands not working

Note: I am on Windows 10 64 bit running the latest LTS Node build.
It all started when I tried running the command npm i -g create-react-app and I get a message saying that npm is not a command.
I checked my PATH and I believe I have the proper directories in there.
I navigated to the directory of npm and tried running the command again, but it still didn't work. I found that the command npm.cmd worked in any directory. So tried running npm.cmd i -g create-react-app and that worked! I also had to use the the command create-react-app.cmd my-app, instead of create-react-app my-app. I thought I was set and I could just use those .cmd commands for the things I needed to do; however, when I tried to run the command create-react-app.cmd my-app and got this as a result:
I have looked in the file that is ran when using this command create-react-app.cmd my-app and there is no sign of npm being called. Turns out Node is being called in that file with the command below. I know this because when I run it by itself and I get the same output to the console seen in the previous image.
"node" "C:\Users\Allen\AppData\Roaming\npm\\node_modules\create-react-app\index.js" my-app
it was called in the create-react-app.cmd file like this "%_prog%" "%dp0%\node_modules\create-react-app\index.js" %*
I am at a loss. I could continue down this rabbit hole and try and find the node file that is calling npm and change it to npm.cmd but I would rather find a way to get the npm and create-react-app commands working as they are suppose to. At the very least I can just spin up a VM and work in that. It is just annoying that I can't get Node to work properly for me.
Use the command npx create-react-app my-app this will help you create react projects.
Also check the documentation : https://reactjs.org/
First check that you have npm installed on your machine and the version. You can just type npm version. Since npm version 5.2.0 npx is pre-bundled with npm, which is a CLI tool whose purpose is to make it easy to install and manage dependencies hosted in the npm registry. So try using npx create-react-app app-name. You can confirm that you are able to use npx by running which npx. If it is not available then you can install it by running npm install -g npx.

bash: create-react-app: command not found (pretty sure it's my $PATH)

Let me preface by stating that this is my first post, and also I can’t retrace my steps to where the create-react-app command no longer works in my Terminal. Last week, when I was practicing how to work with ReactJS I was able to use the command create-react-app and had been able to initialize a React project. However, I’ve been fiddling plentifully with NodeJS and NPM stuff simultaneously, and now when I call the create react-app command this is the output:
bash: create-react-app: command not found
I’m pretty sure it has to do with my $PATH, however I’m not experienced with making edits through vim
when editing my .bash_profile. In my attempts to diagnose and fix the problem, here is what I appended to my $PATH through vim:
export PATH="/usr/local/bin:$PATH"
Nevertheless, I know the order of $PATH matters, but I’m naive as to whether I should prepend or append the $PATH above?
Here is what is output when I echo $PATH:
/usr/local/heroku/bin:/usr/local/bin:/usr/local/sbin:~/bin:/Users/bjornjohnramos/.rbenv/bin:/Users/bjornjohnramos/.rbenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/bjornjohnramos/.npm-packages/bin/express
-> /Users/bjornjohnramos/.npm-packages/lib/node_modules/express-generator/bin/express-cli.js:/Users/bjornjohnramos/.npm-packages/lib:export
PATH="/usr/local/bin:$PATH":export
PATH=$PATH:/Users/my_name/.npm-packages/bin/
my node and npm versions:
node v6.9.1
npm 4.2.0
Who knows what happened? But maybe we can just fix it by reinstalling...
npm uninstall create-react-app
npm uninstall create-react-app -g
npm install create-react-app -g
The first two commands will uninstall create-react-app locally and globally. (Not sure how you may have installed it. Harmless to run both.) The third installs globally, and should set up the path for you as needed.
use command npx create-react-app my-app rather than using npx create-react-app my-app that will resolves your bash: create-react-app: command not found err on windows.
Hope this is helpful
Happy coding...

Resources