我试图使用本指南安装尾风文件3.0.1,但是当我在我的react代码中添加了tailwindcss类时,它没有工作。我遵循这个指南来集成顺风以作出反应:https://tailwindcss.com/docs/guides/create-react-app
我使用npx creat-react-app myApp而不是npx create-react-app@next --scripts-version=@next --template=cra-template@next my-project创建了一个react应用程序。
任何人都可以帮我这个忙。
发布于 2021-12-11 15:41:26
我尝试过许多解决方案,为了成功地将React与Tailwindcss V3.0.1一起使用,安装的第一行是至关重要的:
npx create-react-app@next --scripts-version=@next --template=cra-template@next my-project但是我找到了简单的解决方案,在文档中安装所有类似的东西,并在Public文件夹中将这一行添加到您的index.html中。
<script src="https://cdn.tailwindcss.com"></script>如下所示:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<title>React App</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
</body>
</html>发布于 2021-12-20 21:47:59
安装的主要问题是,顺风版本3依赖于最新的react脚本版本,它支持postCSS编译顺风,而不使用像craco这样的额外工具。
您只需将package.json中react脚本的版本更改为"5.0.0-next.58“,并使用npm安装或纱线安装重新安装包。您可以访问此回购协议,以更好地理解https://github.com/adamwathan/tailwind-cra-next。
发布于 2021-12-24 07:11:45
我也遇到了同样的问题,并找到了解决方案:https://phoenixnap.com/kb/update-node-js-version
我更新了我的节点js,因为当前的版本与尾风was v3.0不兼容。(我将其从14.16.0更新为17.3.0)
首先检查您的节点版本:node -v
如果它低于v16,那么考虑更新。
运行此命令将节点js更新为最新版本:
npm cache clean -f
npm install -g n
sudo n stable之后,删除您的node_modules文件夹并通过运行yarn或npm i重新安装它
https://stackoverflow.com/questions/70313432
复制相似问题