What are all commands for npx create-*? - node.js

I know npx create-react-app and npx-next-app what are all others app npx support?

npx is a program that downloads any package on npm. create-react-app isn't a command for npx, rather, you're telling npx:
Download react-create-app
Cache it (but not in the current directory, so it will stay 'clean')
Try to run it as a program (the package.json file says how to do that, in this case: "run node ./index.js")
npx knows nothing of React or Next.js and it doesn't have these things built in. All it knows is about is npm and how to run any (executable) package it downloads from there, like npx gulp or npx serve.
If you're working with a new framework and you're wondering if there's a utility to quickly set up a project, just search NPM and see what pops up.

There is no set list because npx is a package runner for Node.js. Running npx create-react-app will try to find the package create-react-app and run it. The package will be downloaded if not locally installed.
Therefore, the list of supported commands for npx is "everything included in the repositories used by NPM". You can even create your own package, not visible to anybody else, and run it with npx.

Related

React Js, Template Not Provided On npx create-react-app <app name>

I'm starting a new react app using the
npx create-react-app <app name>
and am recieving an error of a template was not provided do the following ->
npx uninstall -g create-react-app
Well, I have done it and it hasn't helped. I've tried updating the current nodejs and npm versions, I've done a fresh install of nodejs, and I've cleared the npm and npx caches. I've also tried using specific create-react-app versions such as
npx create-react-app#latest(or some other version)
Nothing works, no template is ever provided, and I'm a little lost. Does anyone know another potential workaround? I'm open to manually downloading a folder containing the npx create-react-app post-completion contents if such a thing exists.
The React docs point out that you may have create-react-app installed via Yarn instead of NPM, and can try this also:
yarn global remove create-react-app
This SO answer suggests that if the npm uninstall -g create-react-app doesn't work, you can manually look to see if and where create-react-app may be installed.
If npm uninstall -g create-react-app stated above does not work. Type which create-react-app to know where it is installed. Mine was installed in /usr/bin folder. Then do sudo rm -rf /usr/bin/create-react-app.
Are you on Windows or Mac/Linux? The which command works on Mac/Linux, but not on Windows. I don't know the best way to do this on Windows, but this thread has some suggestions for PowerShell.
My understanding of the npx command is that it psuedo-installs the package (in this case, create-react-app) to ensure that we're using the latest available. It's convenient and recommended, but it isn't required. If you continue having issues, I would personally try fully installing create-react-app to see if I can scaffold a new project that way:
npm install -g create-react-app
create-react-app my-app

Huge unsolved problem with npx create-react-app

I have huge problem when trying to create new react app with npx create-react-app my-app. I have no completely deleted my Node, npm and npx two times and downloaded again and I have checked that my $PATH is usr/local/bin so everything should be okay but every time no matter what I do it says the following:
MarkT#Mark-MacBook-Pro ~ % cd Desktop/
MarkT#Mark-MacBook-Pro Desktop % npx create-react-app my-app
Need to install the following packages:
create-react-app
Ok to proceed? (y)
And after proceeding it says the following:
You are running create-react-app 4.0.3, which is behind the latest release (5.0.0).
We no longer support global installation of Create React App.
Please remove any global installs with one of the following commands:
npm uninstall -g create-react-app
yarn global remove create-react-app
The latest instructions for creating a new app can be found here:
https://create-react-app.dev/docs/getting-started/
MarkT#Mark-MacBook-Pro ~ %
After that when I follow instructions and copy the npm uninstall -g create-react-app or yarn global remove create-react-app it starts this all over again and says:
up to date, audited 1 package in 195ms
found 0 vulnerabilities
MarkT#Mark-MacBook-Pro ~ % npx create-react-app my-app
Need to install the following packages:
create-react-app
Ok to proceed? (y)
I have searched the whole internet and hasn't found a solution, please I need some experts advice on this one this is killing, am I doing something wrong?!?!
based on your description and so, out of the blue, i would say your current node context is polluted somehow.
as you use *nix system with the macbbook, i would suggest to use nvm to create/have a fresh new, detached and independent from your system nodejs context, to make sure you have no other pollutions
I've got exactly the same problem. This script has worked for me:
npx create-react-app#latest my-app

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.

Create-React-App does not create starter template

I'm trying to create a new project with the typescript template as per these instructions.
npx create-react-app app-ui --template typescript
Although it installs all the node modules it does not create the starter project nor does it use the provided template. I get this message:
A template was not provided. This is likely because you're using an outdated version of create-react-app.
Please note that global installs of create-react-app are no longer supported.
I'm attempting to follow the instructions and delete the global install of the cli but that also doesn't work:
npm uninstall -g create-react-app
up to date in 0.037s
No matter what I do I cannot uninstall the cli. What is going on?
Edit:
I was able to get it partially working on PC.
npm remove create-react-app
then
npx create-react-app my-app [--template typescript]
I tried with brackets and although the template project is there it isn't in typescript. There's something very wrong with the cli right now.
Edit:
This post solved the issue of not being able to uninstall the cli. Hope this helps someone and please upvote the OP.
For OP:
Your brackets are out of place.
For your case, the documentation docs says to use:
npx create-react-app my-app --template [template-name]
or
npx create-react-app my-app --template typescript
For everyone else:
Uninstall (I'm on Linux/Ubuntu)
sudo npm uninstall -g create-react-app
Then run:
npx create-react-app my-app
Note: Be sure that all the folders/files were removed on the uninstall. If you're having trouble accessing a the react folders in your linux setup as I was (due to permissions), gain access and remove by:
sudo chown -R $USER /usr/bin/create-react-app
(...and then do the npx command.)
I resolved this issue by sudo npm uninstall -g create-react-app
but this did not remove create-react-app, so I had to check in which directory it is located. In the terminal, if you type:
which create-react-app
it will give you some directory like /usr/local/bin/create-react-app
Now do:
rm -rf /usr/local/bin/create-react-app
This will remove create-react-app manually. Now you can start creating react app using
npx create-react-app my-app
I was having the same problem. This works for me (Linux)
Step 01.
sudo npm remove create-react-app
Step 02.
sudo npm uninstall -g create-react-app
Step 03.
npx create-react-app my-app --template typescript
I hope this helps.
Create React Startup template
1.npx create-react-app your_app_name
2.cd your_app_name
3.npm start
Even if you ran npm uninstall -g create-react-app create-react-app may still be installed. You can check by running which create-react-app. If a path is returned create-react-app is still installed. You can delete the module with rm -r ${returned path}. After that running npx create-react-app app-ui --template typescript should work without errors or warnings.
I came up with 3 solutions which I applied step by step when I faced this situation.
First step: From Official manual,
If you've previously installed create-react-app globally via npm install -g create-react-app, we recommend you uninstall the package using npm uninstall -g create-react-app to ensure that npx always uses the latest version.
https://create-react-app.dev/docs/getting-started
You can use these commands below:
npx create-react-app my-app
npm init react-app my-app
yarn create react-app my-app
Second step (If first one doesn't work):
Sometimes it may keep caches.then you can use these commands given below.
npm uninstall -g create-react-app
npm cache clean --force
npm cache verify
yarn create react-app my-app
Third step:(If these 2 won't work)
first uninstall via npm uninstall -g create-react-app,then check if you still have it "installed" with which create-react-app command on your command line. If you got something like (/usr/local/bin/create-react-app) then run this rm -rf /usr/local/bin/create-react-app (folder may vary) to delete manually.
Then again install it via npx/npm/yarn.
NB: I succeed in the last step.
When i executed
create-react-app hello
only generated below folder structure, with notification
"A template was not provided. This is likely because you're using an outdated version of create-react-app.
Please note that global installs of create-react-app are no longer supported."
node_modules
package.json
yarn.lock
Followed below steps to resolved
// Uninstalling create-react-app package
npm uninstall -g create-react-app
After that i am ready to create new react app through "npx"
For ES6 flavour (Default it will take ES6 language)
npx create-react-app hello-world
For Typescript flavour
npx create-react-app hello-world --template typescript
Following are the folder structure after running above cmd
README.md
node_modules
package.json
public
src
yarn.lock
yarn start //Works fine
node: v10.16.0
npm: 6.10.2
My solution ended up being a little different than yours so I will add it here just in case someone has a similar issue. Apparently I installed create-react-app globally with yarn which I could see when I ran which create-react-app which resulted in a path like .../.config/yarn/global/node_modules/.bin/create-react-app. Running yarn global remove create-react-app removed this package and then I was able to run npx create-react-app app --template typescript successfully.
Install create-react-app
In the beginning, we have to install create-react-app tool. It’s a tool provided by React.js creators, which allows installing ready to use React.js application, with all needed dependencies. To install the tool, we have to use the following command in the command line:
npm install -g create-react-app
Create the application
Now, it’s super easy to create our first application using the create-react-app tool. We can do it with a single command in our command line. First, navigate to the folder where you want to have your application through the command line, and then run the following command, where reactapp is the name of our application:
npx create-react-app reactapp
You can feel free to set a different name for your application. If the process finished successful, you should have your folder with the app ready! Let’s start the application now!
Start the application
Let’s start our reactapp with the following commands:
cd reactapp
npm start
The first command is used to enter the folder of our application, and the second one starts our app. By default, the application is open at localhost:3000, but we can change the port in the settings.
Link: https://dev.to/duomly/how-to-create-the-react-app-in-5-minutes-1bmb
Hpe this helps!
For Windows users, follow two steps
npm uninstall -g create-react-app
Then
npx create-react-app jamming
keep updating your node and npm, latest stable version
Uninstall create-react-app using command:
sudo npm uninstall -g create-react-app
Since npm is not supporting global use of npm modules.
install create-react-app boiler-plate as usual using command:
npx create-react-app my-app
it works!!
I faced the same problem using Command Prompt in Windows, but then I tried the following steps on Powershell it worked. If still it is not working then Run Powershell as Administrator.
npx create-react-app my-app
cd my-app
npm start
I was having the same problem. I tried this
npm install -g create-react-app
Then do the create-react-app app-name It worked out for me.

How do I get globally installed node modules to run on terminal

I am learning how to code with react, and I have installed the create-react-app on my computer. However, globally installed node modules are not running on terminal.
I installed create-react-app globally. I can find find the folder, but I don't know how to get the command to run. Please how do I get globally installed node modules to run on terminal. I used yarn for the installation.
for create-react-app, you should be able to simply run
create-react-app then the name of the App you are creating
so:
create-react-app nameOfApp
Here is some documentation that should help:
https://reactjs.org/docs/add-react-to-a-new-app.html
If you are asking how to start the application, you can use
node server.js
if your entrypoint file is called server.
Alternatively use npm start, documented here: https://docs.npmjs.com/cli/start
To see what is installed,
npm -g list
will tell you what is installed globally.
I finally resolved the issue and this is how I did it:
I found the location where my global packages where being installed and exported the path to the .bin directory
export PATH=$PATH:~/.config/yarn/global/node_modules/.bin

Resources