I read the documentation of reactstrap, and it guide us to install npm package as below;
npm install --save bootstrap
npm install --save reactstrap react react-dom
my question is, is it necessary to install react and react-dom, aren't those two packages are included by default in create-react-app?
Yes, it's installed by default when you are make
npx create-react-app my-app
You alse can instal it with typescript if you want via
npx create-react-app my-app --template typescript
and it will also add #types/react-dom
Yes! it is included in node_modules by default when you use
npx create-react-app app-name
but you may also choose not to use it for some reason. Then you will need to install them and add your project starting files by yourself.
Related
I want to create a React application and I want to use a typescript in this application, at first I went to the React website in order to create an application using typescript and I found that I had to put this instruction in the terminal first:
npx create-react-app my-app --template typescript
And when it finished installing, I put it in the terminal:
npm start
But I got this error:
It looks like you're trying to use TypeScript but do not have typescript installed
I opened the terminal and wrote this instruction:
npm install
then i run the app:
npm start
But the error is still there
How can I solve the problem?
I solved my problem with the following instruction:
npm install --save typescript #types/node #types/react #types/react-dom #types/jest
or
yarn add typescript #types/node #types/react #types/react-dom #types/jest
have you tried
npm install -g typescript
yes i tryed but still with error
Have you tried
npm run start
Consider upgrading Next.js 11 to 12 or to latest version. Also, you need to upgrade types to latest for react and react-dom. Here is a brief documentation about that:
https://nextjs.org/docs/upgrading#upgrade-nextjs-version-to-12
I've been trying to create a react-redux file but I've been getting some error in that.
The problem I am getting is this.
C:\Users\Maaz Parkar\Desktop\REDUX LOGIN>npx create-react-app my-app --template redux
Need to install the following packages:
create-react-app
Ok to proceed? (y) y
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/
C:\Users\Maaz Parkar\Desktop\REDUX LOGIN> npm uninstall -g create-react-app
up to date, audited 1 package in 250ms
found 0 vulnerabilities
You're not installing it correctly.
First make sure npm and node are up to date and then open the Command Prompt and write:
npx create-react-app <name>
<name> is the name of your app.
After than is done cd into the folder and run
npm i redux react-redux reduxjs/toolkit
or with yarn:
yarn add redux react-redux reduxjs/toolkit
Try this library
npm i -g create-react-redux-app-structure or yarn add global create-react-redux-app-structure
create-react-redux-app-structure my-app
cd my-app
It will create more structured project easily.
I kind of rushed into creating a React app based on a tutorial that used yarn. Now I'm going to re-create the app from scratch because I'm not satisfied with the reactstrap library, and I'd like to switch to react-bootstrap.
I've re-installed node. However, when I run create-react-app, it says to use "yarn" instead of "npm" as follows:
yarn start
Starts the development server.
yarn build
Bundles the app into static files for production.
yarn test
Starts the test runner.
yarn eject
Removes this tool and copies build dependencies, configuration files
and scripts into the app directory. If you do this, you can’t go back!
We suggest that you begin by typing:
cd react-test
yarn start
I'd like to use npm because it seems like it's more widely used and there are more examples based on it. Am I stuck with yarn, or can I go ahead and use npm?
You can either
1) Remove yarn.lock, and running npm i,
or
2) Run create-react-app app --use-npm
1 ⇢ If you have installed create-react-app then use:
create-react-app --use-npm
2 ⇢ If you are using npx command then use:
npx create-react-app --use-npm
3 ⇢ For existing yarn app, remove the yarn.lock file and run:
npm i
or
npm install
Install create-react-app npm i -g create-react-app --use-npm
Go to desired path using cd command
Add --use-npm create-react-app my-app-name --use-npm
This command will create a folder with the name that you mentioned inside your current path . This folder consists all necessary configuration files needed for a starter code for react application
# Run this to create-react-app using npm
npx create-react-app my-app
# Or run this to create-react-app using yarn
yarn create react-app my-app
I dont know if this helps. But I was having the same problem and did this
npx expo-cli init --npm
and it installed with npm
hope this helps you or someone in the future
For latest versions, the flag is changed to --npm
So if you want to use npm then use it like
npx react-native init YourProject --npm
this is the error message that shows when i try to install react I'm setting up a new project for react, and when I try to npm install create-react-app it shows error like missing dependencies in package.json.
npm install create-react-app
npm install create-react-app my-app
I expected that the dependencies should be added inside my package.json but nothing appers.
If you have installed npm 5.2+, you can just use npx to execute node packages, or you need to install create-react-app globally to make it executable globally.
npm version
npm install -g create-react-app
create-react-app my-app
npx version
npx create-react-app my-app
I recently installed yarn on my machine but was using npm before. For my current project in React I want to use npm again.
However, if I run create-react-app it is built with yarn.
How can I switch so that it is created with npm?
You can use the --use-npm flag:
create-react-app my-project --use-npm
If it's an existing project you can just remove yarn.lock and continue using it with npm.