create-react-app command not found in ubuntu 16.04 LTS - reactjs

I tried to install create react app using sudo npm install -g create-react-app on my terminal, then this message appeared:
/home/mahi/.npm-global/bin/create-react-app -> /home/mahi/.npm-global/lib/node_modules/create-react-app/index.js
+ create-react-app#1.4.3
updated 1 package in 11.7s
Then when I am going to run the command create-react-app hello-world, it says create-react-app command not found. Then I searched for many solutions, I tried almost all of them, but nothing improved, showing the command not found again and again.

I had this same problem and this is how I solved it.
It will work on Ubuntu 16.04 as well as Ubuntu 18.04.
First, open up terminal and run this command:
sudo npm install -g -y create-react-app
After that, you will be able to use the create-react-app anywhere on your machine because it is saved globally.

Are u sure to run npm install with sudo? I had same problem and terminal couldn't write to folder with commands. Does your /usr/local/lib/node_modules/ folder contains create-react-app?

are you using create-react-app with sudo? because if you installed the package using sudo npm install create-react-app then it is installed for this user, try sudo create-react-app and if it works then you should change ownership to your user

I use to have the same problem in the terminal when i write npm install -g create-react-app and them create-react-app my-first-app.
So i went react doc and i find npx create-react-app my-first-app that worked for me.
Hope that will help.

If you read carefully then you will see after installing Yarn it tells you to add the following thing in your path.
export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"
~/.yarn/bin is for yarn binaries only.
Try it!
Source: https://github.com/yarnpkg/yarn/issues/5156

Related

I can't update create-react-app, any suggestion?

SS of my terminal
Hi, I've a problem trying to update this, I tried everything like a uninstall, install, cache clean, with yarn, etc, but when I checked the version still in 2.1.8
I've got it :D
I tried the answers but I still have the same problem, so I followed these steps on my terminal:
npm uninstall -g create-react-app
which create-react-app
> /usr/local/bin/create-react-app
rm -rf /usr/local/bin/create-react-app
npx create-react-app app_name --template typescript
thanks everyone for your answers ;)
Make sure to use 'npx' instead of 'npm'
npx create-react-app AppName
If you ever installed the create-react-app package globally you'll need to remove that, it will supercede local versions:
npm uninstall -g create-react-app
Then you can install whatever version you'd like with whatever package manager you'd like, such as:
npm install create-react-app

public, src,and scripts folder not created while using create-react-app

I am trying to create a new project using create-react-app using the command given on the docs i.e npx create-react-app my-app but it doesn't contain folders like public src and script.
Try with these steps :
npm rm -g create-react-app
npm install -g create-react-app
npx create-react-app my-app
Source
I tried all the suggestion stated above but none works for me. This suggestion at 8097 works for me. Basically, I just run npx create-react-app#latest your-project-name
For those who keep trying and still doesn't work, you might have the same problem as me.
Because the global installs of create-react-app are no longer supported you might have it installed on your machine, thus have the old version running whenever you try to npx create-react-app. There are 2 very easy steps: remove create-react-app, then run the npx command.
It will look like this:
sudo npm rm -g create-react-app (sudo is needed on macs to grant you permission, it will ask for your password, type it in and hit enter)
npx create-react-app my-app
Should solve your problem there
Still didn't got to know the issue. But i tried :-
npm rm -g create-react-app
npm install -g create-react-app
npx create-react-app my-app
This also didn't worked for me. So I uninstalled node and installed it again. It worked for me
If someone's terminal get stuck and the initialization does not completes, just open the resource monitor and resume the cmd ,
1.window+R key- type 'resmon'
2.Locate the cmd process ,right click and resume it, initialization will be complete.
had the same issue on my mac.
The correct way is if you've previously installed create-react-app globally via npm install -g create-react-app, you have to uninstall the package using npm uninstall -g create-react-app in order npx to uses the latest version.
Tips: Try npx create-react-app --info to check if npmGlobalPackages includes create-react-app. If cra is included then try the below command which create-react-app and rm -rf the outputted path.
Last but not least, force npx to use latest:
npx create-react-app#latest your-project-name
You can uninstall a globally installed package with this:
npm uninstall -g create-react-app
Install Npm version of
14.18.2
Install Below Link: https://nodejs.org/dist/v14.18.2/win-x64/node.exe
It is not working for me on windows machine. It worked when I ran below commands from git bash:
npm install -g create-react-app
npx create-react-app my-app
Follow the following steps and that should solve your problem.
sudo npm rm -g create-react-app (Do not skip sudo if you are a macOS user).
npx create-react-app my-app (npm 5.2+ and higher)
or
npm init react-app my-app
or
yarn create react-app my-app (if you use yarn)
I had the same problem, this how I solved it.
When I try to run npm rm -g create-react-app, it shows an error.
So I went to the node modules directory (for Mac /usr/local/lib/node_modules) and delete create-react-app directory and reinstall create-react-app using npx create-react-app my-app.
For Windows users who are facing this issue:
Open Task Manager and check if the Windows Command Processor process is set to Suspended.
If it is set to Suspended, open Resource Monitor and click on the CPU tab.
From within the CPU tab, locate and right-click on cmd.exe and and select Resume Process.
Click the source link below for a more detailed explanation (including screenshots).
Source: Github Issues
I solved it using following commands
npm uninstall -g create-react-app
yarn global add create-react-app
In my case, i tried installing with yarn but don't downloaded all files
So I tried this
npm install --global yarn
npm uninstall -g create-react-app
npm install -g create-react-app
npx create-react-app my-app-youtube --use-npm
And it worked, with npm, i downloaded all template
:D
Ok ok... If you are still not getting any solution
Go to other Folders of your computer(like documents, Downloads) and then Create a folder for your app and Open it with VsCode(preferable)
On the Terminal ( Or Powershell which is also avaliable in VsCode)
1st Command: npm uninstall -g create-react-app
2nd Command: npx create-react-app
Hope It Helps :)

Create React App not working

Help! I have no idea what is going on here, create react app is not working I have also tried reinstalling and yet to no avail, please help!
Npm version: 5.4.2
Node version: 8.70
Tried the npm install --save --save-exact --loglevel error react react-dom react-scripts
In my case, "create-react-app" was not installed. to install run this command
npm install -g create-react-app
Once installation successful, try running
npx create-react-app hello-world
If this works for you. Great else comment what worked for you,
Please try this:
npm cache clean --force
I also got the same issue and tried to resolve for a long and finally resolved using this command,
npx create-react-app#latest my-app --use-npm
I had the same problem and had to do the following:
npm uninstall -g create-react-app
npm uninstall create-react-app
After this I was able to create the app with:
npx create-react-app project-app
I had the same problem, and I solved it by:
1. update the npm version (npm install npm#latest -g)
2. clear the cache (npm cache clean --force)
3. create the react project (npx create-react-app todo)
(create-react-app was already installed)
I had similar issue while tried creating new react app with create-react-app, but related to some random JSON reading issues while installations like.. >= 5.0 || 4.0 ..
But the fix below solves multiple and similar issues.
First of all, make sure you have required or latest version of node installed.
npm install npm#latest -g
Before using create-react-app make sure you clean npm cache using npm cache clean --force
Now, is should be fine to create new react app with npx create-react-app tl-app or npx create-react-app . if you want to create current directory as project root.
Make sure you are not running any antivirus, stop/pause all antivirus or protection software.
You can also try
use create-react-app projectname --save
or create-react-app projectname --save-exact and start again
OR
as the error suggests, you should use a newer version of node. You are using 8.9.4, you should probably use 8.12.0 LTS.
It sets up your development environment so that you can use the latest JavaScript features, provides a nice developer experience, and optimizes your app for production.
You’ll need to have Node >= 8.10 and npm >= 5.6 on your machine. To create a project, run:
npx create-react-app my-app
cd my-app
npm start
Note:
npx on the first line is not a typo — it’s a package runner tool that comes with npm 5.2+.
Create react app provides more information regarding this.
It may be the problem of cache also, so can also try:
npm cache clean --force
Edit 1: This may be due to slow internet speed, Please check the
internet and try again.
npx create-react-app .
( the .) means create project on this folder so you should manually create if you do that
For the windows machine following command worked for me
yarn create react-app my-app
cd my-app
yarn set version berry
yarn
yarn start
The problem on my machine was caused by yarn. I am windows 10 and after uninstalling yarn using npm uninstall -g yarn, my script run correctly. So
Open terminal and type: npm uninstall -g yarn
Once done, close terminal and open new one
type create-react-app (app name) and this should create your app :)
Please note that the above steps assume that you already have node and react-cli installed on your machine.
on Ubuntu 18.04
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
What I did, is going to
C:\Users\mycomputerName\AppData\Roaming\npm\
I changed the name of this file
create-react-app.ps1
to
create-react-appOld.ps1
or you can delete it, then it worked fine
Tried all the above methods but no luck:(
Step1 : Reinstalled Node js
Step2 : Check whether environment variables has been created. if not create one for nodejs,npm and composer
Step3: Also add "C:\Windows\System32" to the global PATH environment variable.
Step4: Then use "npx create-react-app my-app" to create react project
Step5: Run the commmand : cd my-app and npm start
Step6: It will work
I finally got it to work. An anti-virus in my system was causing it not to work property. I unistalled it and it's working as expected.
After no luck with updating my npm version and doing npm cache clean --force I ended up just doing a fresh install of node which fixed the issue for me.
HAD the same problem. Running Node with cra. installed cra -g for starters.
npm install -g create-react-app
then downgraded react-scripts to version 2.1.8
npm install react-scripts#2.1.8
created a .env file in root directory and added this to it.
DB_HOST=localhost
DB_USER=root
DB_PASS=s1mpl3
SKIP_PREFLIGHT_CHECK=true
Then you do the typical delete node_modules folder and the package-lock.json file.(NOT PACKAGE.JSON!!!)
then:
npm install
npm start
This worked for me. Sorry I'm not more informative on why this worked for me. I'm still trying to understand why it didn't work in the first place.
I just did it now after messing around with it all yesterday.
Installed react globally like people have said.
then I used 'git bash here' to open terminal in the directory i want
oddly, it worked when I removed npm. I know it's weird, I've never had to do that and it makes no sense but its working so:
create-react-app my-app-name
I'm on windows 10 by the way.
If there is anyone having this issue that you can not find your project when you
yarn create-react-app (name of project)
npx create-react-app (name of project)
then just be sure that you are in the right directory.
use this command in your terminal
cd ..
now search the project name by
cd (project name)
you should find your directory here.
Please do this, I hope it will fix all of your problems
1- npm i -g create-react-app
2- create-react-app my-app
Find the folder and where a folder named npm is present and add it into environment variables (path)
I also experienced the same problem and SOLVED IT.
This is what I did.
Restart your machine(computer)
Deactivate your anti-virus. I chose the "permanently" option
Open the terminal and run the "create-react-app" command again, It will definitely do the trick.
Activate your anti-virus
And get working :-)

Command not found returned in terminal on almost every line

I'm trying to work with AngularJS but I can't even get pass installing it via Terminal.
I enter this onto the command line
npm install -g #angular/cli
I get this as a result
- bash: npm: command not found
I seem to be getting this same error log on almost every command, the rest return nothing
I'm stumped as to why it's not working.
For reference I'm using OS X 10.9.5
Make sure you got node installed which comes with npm
https://nodejs.org/en/
You error looks like you don't even have node installed on your computer, first of all, you need to install node js on you computer, once you’ve installed Node.js, you can make sure you’ve got the very most recent version of npm using npm itself: sudo npm install npm -g.
Then you can continue your installation with the step below:
To install #angular/cli locally run npm install #angular/cli --save, while to install it globally run npm install -g #angular/cli.
But if it requires a root access, then you have to include the sudo which will then be sudo npm install -g #angular/cli.
I figured it out. I needed to adjust the .bash_profile by entering this
echo "export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/b‌​in" >> ~/.bash_profile
Thanks to everyone who gave advice :)

Error: Cannot find module '#ionic/app-scripts'

I'm new to Ionic. I was following the Ionic documentation "get started", created a project sample named "super". The problem is that when I run the command line ionic serve in the project directory, it threw an error Error: Cannot find module '#ionic/app-scripts'
Try installing app-script from npm
npm i #ionic/app-scripts
To get the latest #ionic/app-scripts, run the following command:
npm install #ionic/app-scripts#latest --save-dev
app-scripts currently compatible with node 6 and 7.
İf you installed node 8, then please uninstall and install node 6 stable version.
This solved error and now i can use ionic 3, angular 4 .
Take care!
do not downgrade the node version, update the version of "app-scripts":
To get the latest #ionic/app-scripts, please run:
npm install #ionic/app-scripts#latest --save-dev
I was facing same issue, here is what I did-
Removed node_modules from directory (Manually).
open project dir
run this command-
npm install
That fixed those errors for me.
See here.
I had this issue , i solved it by deleting node_modules/ folder and ran the command npm installnow my app works
I tried every non-downgrade solution mentioned in this thread, in all kinds of ways and none of them worked. With nothing left to lose, I went down the downgrade route (I used sudo apt-get purge --auto-remove nodejs to remove previous 8.x version and then installed the last stable ver on the 6.x branch using the nodesource ppa).
Still got the same errors trying to run in the original project folders, but then I created a new project and ionic serve worked just fine in that space.
FWIW, I did not need to run npm update or npm i #ionic/app-scripts afterwards, but I did find it necessary to adopt the habit of running commands with sudo in front (or you sudo -s into root account).
I ran into the same issue and i had problems fixing it. However i update my app scripts npm install -g #ionic/app-scripts#latest --save-dev to the latest version and my problem was solved
npm install -g #ionic/app-scripts#latest --save-dev
Error: app-script not found/ app-script not installed/ app-script module is not found
Try this work for me, Your also:
- npm cache clean --force
- npm install #ionic/app-scripts#latest --save-dev
- npm install -g #angular/cli
I had the issue, solved by execute cnpm i #ionic/app-scripts.
Just open a new terminal window/session. I could not figure it out, but it's probably related to env.
None of the options worked for me.
But I could make it work by updating node with
npm update
After this, the problem was solved and the application started.
Good Luck.
I had the same problem and here is what worked for me
I was trying to run the program using VSCode terminal, Instead I used the windows cmd and it ran perfectly. I think the error is in VSCode terminal, it cannot identify the app-scripts module inside the project. Maybe it will be fixed in a later update.
Delete node_modules and package-lock.json
rm -rf node_modules package-lock.json
npm install
Reference:
https://github.com/ionic-team/ionic-cli/issues/3399
After half a day trying to solve this
And after:
python version error
node-sass misconfiguration error
I did the following
Remove node-modules folder
Run "npm audit fix --force"
Downgrade webpack installation "npm uninstall webpack && install webpack#3.12.0"
The last one because ionic build was giving me an error on that package after the audit
In my case, I need to set NODE_ENV to production then it installs successfully
set NODE_ENV=production
npm install #ionic/app-scripts#latest --save-dev
You must create the project as administrator if you have mac or linux uses sudo, if you have windows run the console as administrator and create the project
My issue was solved after run this script:
npm i #ionic/app-scripts

Resources