You develop apps in the context of an vite-React workspace.
To create a new workspace and initial starter app just follow the below steps
npm create vite@latest
Project name : my-app
Select a framework: React
Select a language: Typescript
The vite installs the necessary React npm packages and other dependencies. This can take a few minutes. This creates a new workspaces and a simple Welcome app, ready to run.
The vite includes a server, so that you can build and serve your app locally.
cd my-app
npm run dev
The yarn or npm serve command launches the server, watches your files, and rebuilds the
app as you make changes to those files.
The run dev
just Option automatically opens your default
browser to http://localhost:5173/.
After initialize a React Vite project install the required dependencies for Tailwind CSS. Run the following command in your project directory:
npm install -D tailwindcss@latest postcss@latest autoprefixer@latest
Generate a Tailwind CSS configuration file by running the following command:
npx tailwindcss --init
This will create a tailwind.config.js file in your project's root directory.
Step: 3 Configure PostCSSCreate a "postcss.config.js" file in your project's root directory and add the following configuration:
export default {
plugins: {
"postcss-import": {},
tailwindcss: {},
autoprefixer: {},
},
};
If you have already download and install node.js and React then ignore prerequisites.
Download latest version of node.js from
nodejs.org.
Install Node.js using downloaded file.
To check your node version, run node -v in a terminal/console window (cmd)
To install the React using npm, open a terminal/console window and run the following command.
npm install react
(or)yarn install react
Ynex/vite-file>
npm install
(or)yarn install
Once you serve your application by default it will take their default port using http://localhost:5173/npm run dev
(or)yarn run dev
npm install
If your are using npm install, You have to delete the
yarn-lock file
(or)
yarn install
If your are using yarn install, You have to delete the
package-lock.json file
basically npm i is used to install all dependencies or devDependencies from a package. if there will be any dependencies which need to be installed but getting error message while installing, then --force will help to install those dependencies.
The --force argument will force npm to fetch remote resources even if a local copy exists on disk. It will be on a last-dependency-downloaded-wins basis and will overwrite any previously downloaded dependencies.
npm install --force
if there is peer dependency issues while installingnpm install--legacy-peer-deps
we have to use only one file example: (for yarn yarn-lock) & (for npm package-lock.json) file
yarn run build
(or)npm run build