如何在 Termux 中安装 React 和 Tailwind

你好!这是我在 dev.to 上的第一篇帖子。我希望你们都能理解我的教程。如何在 termux android 上安装 react。😁😁

**1. 在 termux 中更新你的软件包**

首先,您需要更新 termux 中的软件包。以下是如何更新软件包的命令:

pkg update && pkg upgrade -y

**2. 在 termux 中安装 nodejs**

接下来,需要在 termux 中安装 nodejs:

pkg install nodejs -y

**3. 创建你的 React 应用**

您需要在此处创建应用程序,命令如下:

npx create-react-app 
cd 

例如

npx create-react-app react-app
cd react-app

**4. 安装 tailwind css**

您需要使用 npm 安装 tailwind,命令如下:

npm install -D tailwindcss
npx tailwindcss init

**5. 编辑配置 tailwind css**

您需要在 `tailwind.config.js` 文件中配置用于 react 的 tailwind css。您可以使用 nano 或 vim 打开文件配置。

如果你在 termux 中没有 nano,你需要安装它

`pkg 安装 nano -y`

现在你可以像这样使用 nano:

`纳米`

因此,我们回到主题,使用文本编辑器打开 termux 中的文件配置,如下所示:

nano tailwind.config.js

编辑内部文件或用以下内容替换文本:

/** @type {import('tailwindcss').Config} */
module.exports = {
  content: [
    "./src/**/*.{js,jsx,ts,tsx}",
  ],
  theme: {
    extend: {},
  },
  plugins: [],
}

之后使用 `ctrl + x, y, enter` 在 nano 中保存文件

**6. 在 css 文件中添加@tailwindcss**

使用 nano 打开文件夹 `./src/index.css 中的文件 index.css ,如下所示:

nano ./src/index.css

在文件顶部添加 `@tailwindcss`

@tailwind base;
@tailwind components;
@tailwind utilities;

**现在您可以在 termux 中使用 tailwind 运行 react 应用程序 :)。您可以使用以下命令运行 react 应用程序:**

npm run dev

或者

npm run start

这就是我的教程,我希望你们都理解我的教程呵呵。因为这是我的第一篇帖子,你可以支持我,我会在下次发布教程哈哈。

**来源 :**

https://tailwindcss.com/docs/guides/create-react-app