installed create-react-app without -g - reactjs

I have installed create-react-app without -g
C:\Users\user1\projects\react>npm install create-react-app
but when I run
C:\Users\user1\projects\react>create-react-app my-app1
I get the following error
'create-react-app' is not recognized as an internal or external command, operable program or batch file.
can anyone please help me understand the role of -g flag
what if I dont want to install it globally?
How do I make it work without installing globally?

what if I dont want to install it globally?
How do I make it work without installing globally?
The package is designed to be installed globally. Please use it as intended.
If you don't want to permanently install it, in recent Node versions you can actually run it without installing through npx:
npx create-react-app my-app

If you have installed any npm module locally it will be stored in the .bin folder inside node_modules. To use this, you would have to reference node_modules/.bin/the binary to run. If installed globally, the module's binary will be stored wherever your OS stores executables that are run from the terminal, in Unix/Linux, for instance, it's usually something like /usr/bin(not absolutely sure). This is why installing something locally won't run by simply typing out its name in the terminal. Rather reference it absolutely like this node_modules/bin/the binary to run.

Related

zsh: command not found: create-react-app (what does this mean?)

why is this occurring? I've tried to set my path variable correctly but maybe I did it wrong and hope that's the reason zsh can't find the command "create-react-app" after installing it. I have very little experience in the terminal and am hoping someone can help me out.
On the command line you have to run npx create-react-app (for npm)
This is because when packages are installed globally, they are still just plain JavaScript. You need the npx command to run the installed package's code.

SCSS compilation issue in #material/button/_mixins.scss

issue-screen-shot
I'm getting this issue it's quite troublesome can anyone please help me out reagarding this issue...
I'm getting this issue when trying to build my react project.
build script screen-shot
node-sass already addedd
To get MDC React Components to work with create-react-app you need to set a SASS_PATH environment variable that points to your node_modules directory. To quickly do this on OS X or Linux enter the following in your command line:
export SASS_PATH=./node_modules
If you're on Windows use the following:
SET SASS_PATH=.\node_modules
Rename your src/App.css file to src/App.scss.
You will also need to install node-sass:
npm install node-sass

Removing old versions of create-react-app

I wanted to create a new react app using the create-react-app script. I still had a global version installed which is not supported anymore so I uninstalled the global version and tried creating a new one like this:
npx create-react-app myapp
I then got an error of no template used and that I probably use an older version of create-react-app. I read online and this DID work:
npx --ignore-existing create-react-app myapp
I read that it means I still got an older version even though I did uninstall the global version. So how do I remover any other older version of create-react-app?
The following steps solved the problem of removing an old version and creating a create-react-app.
1 Check version of create-react-app, using npx create-react-app -V.
2 Uninstall any global version of create-react-app, using either npm uninstall -g create-react-app or yarn global remove create-react-app.
3 View the contents of your machine _npx folder, each folder inside represents a version of node installed. Use ls -a /Users/<username>/.npm/_npx/.
4 View the version of create-react-app in a node version found in step 3 in the package.json file. Example nano /Users/<username>/.npm/_npx/c67e74de0542c87c/package.json.
5 Delete the node version folder. Example rm -rf /Users/<username>/.npm/_npx/c67e74de0542c87c. It will get recreated when you run step 6. Alternatively, you can rename the folder to be safe.
6 Create react app. npx create-react-app my-app. You should see the prompt to proceed app creation.
The npx is a tool to execute packages and npm is a tool mainly used to install packages. That's means if you want to execute a package without installing it on your computer and then launch it you can use npx directly.
Uninstall the library globally
Use npm uninstall -g create-react-app then check if is it removed successfully from your machine using which create-react-app. If still exist delete it manually.
Linux
rm -rf /usr/local/bin/create-react-app
-r -- attempt to remove the file hierarchy rooted in each file argument i.e. recursively remove subdirectories and files from the specified directory.
-f -- attempt to remove the files without prompting for confirmation, regardless of the file’s permissions
Windows
del /f/s/q C:\nodejs\node_modules\npm\bin\create-react-app > nul
rmdir /s/q C:\nodejs\node_modules\npm\bin\create-react-app
/f -- forces the deletion of read-only files.
/q -- enables quiet mode. You are not asked if it is ok to delete files (if you don't use this, you are asked for any file in the folder).
/s -- runs the command on all files in any folder under the selected structure.
Finally you able to use the last version with npx create-react-app myapp.
If someone in the future finds this and the above solutions don't help, I found a fix for myself.
I tried everything including the npm uninstall -g create-react-app which seemingly did nothing.
Then I finally found this from an old installation: C:\Users\<username>\AppData\Roaming\npm\
which had 2 react related files, named along the lines of create-react-app.cmd or something similar. Delete anything related to react from that folder.
Then in the same path delete this folder:
C:\Users\<username>\AppData\Roaming\npm\node_modules\create-react-app
If you had none of the above in your roaming folder, then your issue is elsewhere. The above files must have stayed from an old npm react installation which the uninstall command doesn't delete for some reason.
This fixed all problems for me though, and I was finally able to create a functioning project with npx create-react-app.
All the advice tells us remove the globally installed old version of create-react-app - but apparently it was a non-global existing installation that was causing the problem for me.
I had success with
npm uninstall create-react-app
(leaving out the -g flag).
I have no idea where it was, but apparently it is gone now :)
I was running into this on my MB Pro 2012 with Mojave (10.14.6) and tried a bunch of different things after the recommended solutions of
Please remove any global installs with one of the following commands:
- npm uninstall -g create-react-app
- yarn global remove create-react-app
I tried switching to each of my node versions using nvm one at a time and running both of these. I tried uninstalling all of the node versions I had. I ran
which create-react-app
And got nothing.
I tried to see if I could sidestep like the Original Poster, but when I ran
npx --ignore-existing create-react-app myapp
I got an error message saying that the ignore-existing option has now been disabled.
Some posts were mentioning an issue with npm's cache so I ran
nvm cache clear
But no dice. I was reading something other posts and saw some mentions of using homebrew to uninstall node, so I started going through that route:
brew doctor
Then
brew update
Then
brew upgrade
After that, I thought maybe it was installed in the system version of node and that nvm was hiding it from me. So, to get access to system node, I ran
nvm deactivate
Then I ran
which create-react-app
and I again got nothing. Finally, I tried to actually run the command using the system version of node
npx create-react-app my-app
This time, I got:
Need to install the following packages:
create-react-app
Ok to proceed? (y) y
Creating a new React app in /Users/my_username...
It went through with the install this time. Then when I opened another terminal with nvm activated and was able to run
npx create-react-app trying-again
Finally, it worked.
TLDR;
nvm deactivate
npx create-react-app my-app
# say yes when it asks you to install
# close that terminal and open another and you should be able to use the command as normal

Adding dependency gives error: 'react-scripts' is not recognized as an internal or external command, operable program or batch file"

Does anyone else get this issue? When i go to create a new project using create-react-app, and i add any dependency to it other than the stock ones, i.e. react-redux, redux, react-router-dom, i get the following error:
'react-scripts' is not recognized as an internal or external command,
operable program or batch file.
I've tried building with different vs of the modules but that proved pointless.
Any advice on why would be amazing. The versions of the modules are the latest ones.
You are getting that error because you node_modules are either not present their or they are not installed properly because when you are trying to start app with
something start
then it runs the start script from package.json so install the node_ modules properly to start the react app.
Run npm install in the project directory where your package.json is
#Aniruddh Agarwal and Strahinja Ajvaz gave me the hint.
I did start to use yarn for a while but for reason a package name couldn't be installed properly with yarn. I switched to npm install and it worked fine. After trying to run the code it failed. I did npm uninstall package and after that tried yarn add package again. It succeded this time (strange) and the application did start as before.

Installing Definitely Typed packages in VS 2015 RC AspNet5 using Gulp and TSD

I am trying to install angular.d.ts in my MVC6 application and am running into major headaches.
I have set up Gulp to "REINSTALL" any packages I need using tsd, but I cannot figure out how to get the packages installed in the first place. All the instructions tell me to run tsd install xxx or some such but I cannot get Windows to recognize it. I realize I can add it to my path etc. But everyone seems to think I can just run it. Is there some trick I never learned in VS in regards to this?
You should either:
Install tsd globally: npm install -g tsd.
or
Use local executable: ./node_modules/.bin/tsd.

Resources