[英]NexJS Tailwind not loading styles after cloning a github repository
So I'm following a React NextJS tutorial and everything was fine yesterday, but today I had trouble accessing Sanity backend.所以我正在学习 React NextJS 教程,昨天一切都很好,但今天我无法访问 Sanity 后端。 After Googling the solution was to comment out tailwindcss: {}, in postcss.config.js.
在谷歌搜索后,解决方案是在 postcss.config.js 中注释掉 tailwindcss: {}。 But then all the styles in the app stopped working, even if I un-commented tailwindcss: {},
但是随后应用程序中的所有样式都停止工作,即使我取消注释 tailwindcss: {},
Remembering that everything worked last time I pushed to GitHub yesterday I cloned the repo but the issue persists.记得上次我昨天推送到 GitHub 时一切正常,我克隆了 repo,但问题仍然存在。
Then I started the tutorial from scratch, and both Tailwind and Sanity were working perfectly and they still are.然后我从头开始学习教程,Tailwind 和 Sanity 都运行良好,现在仍然如此。 But I was trying to figure out what stops my original app from working.
但我试图弄清楚是什么阻止了我原来的应用程序的工作。
Been bashing my head for hours now and still can't come up with a solution.几个小时以来一直在抨击我的头,但仍然无法提出解决方案。 I even pushed the now working app, cloned it again, and the clone doesn't work while the original of the clone still works.
我什至推送了现在正在运行的应用程序,再次克隆了它,并且克隆无法运行,而克隆的原始应用程序仍然可以运行。 I ran both npm i --legacy-peer-deps and Tailwinds installation
我同时运行了 npm i --legacy-peer-deps 和 Tailwinds 安装
npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -p
The npx command told me that tailwind.config.js and postcss.config.js already exist. npx 命令告诉我 tailwind.config.js 和 postcss.config.js 已经存在。 So I tried cloning the repo, deleting tailwind.config.js, postcss.config,js, and package-lock.json.
所以我尝试克隆 repo,删除 tailwind.config.js、postcss.config、js 和 package-lock.json。 Also ran uninstall command for Tailwind.
还为 Tailwind 运行了卸载命令。 And then again ran npm i and Tailwinds installation.
然后再次运行 npm i 和 Tailwinds 安装。 But it still doesn't work.
但它仍然不起作用。
Here's the repo - https://github.com/RUSHWAYC/tikdok-test.git这是回购 - https://github.com/RUSHWAYC/tikdok-test.git
Here's how it looks like:它是这样的:
Here's how it should look like:它应该是这样的:
Am I missing anything?我错过了什么吗? Any commands that I should be running in the terminal?
我应该在终端中运行的任何命令? Any help would be appreciated.
任何帮助,将不胜感激。
Steps you can follow to fix this issue:您可以按照以下步骤解决此问题:
tailwindcss: {}
from postcss.config.js
, then re-run your development server.postcss.config.js
tailwindcss: {}
的注释,然后重新运行您的开发服务器。After hours of fewer induced hallucinations I figured it out.经过几个小时的幻觉减少后,我想通了。 So I found a way on how to fix the Tailwind styles not applying.
所以我找到了一种方法来修复不适用的 Tailwind 样式。
npm i --legacy-peer-deps
cd backend
(to go to Sanity backend folder) cd backend
(去 Sanity 后端文件夹)npm i --legacy-peer-deps
cd..
npm run dev
So it works now and shows Tailwind CSS applied to the project.所以它现在可以工作并显示应用于项目的 Tailwind CSS。
But then, if you git add.但是,如果你 git add. there are these errors:
有这些错误:
warning: in the working copy of 'package.json', CRLF will be replaced by LF the next time Git touches it
警告:在“package.json”的工作副本中,CRLF 将在 Git 下次接触它时被 LF 替换
warning: in the working copy of 'postcss.config.js', CRLF will be replaced by LF the next time Git touches it
警告:在“postcss.config.js”的工作副本中,CRLF 将在 Git 下次接触它时被 LF 替换
warning: in the working copy of 'tailwind.config.js', CRLF will be replaced by LF the next time Git touches it
警告:在“tailwind.config.js”的工作副本中,CRLF 将在 Git 下次接触它时被 LF 替换
So git reset
that.所以
git reset
了它。
Found this useful post about the first error.找到了这篇关于第一个错误的有用帖子。 - Git replacing LF with CRLF Basically, it's something dumb that I'm even dumber to understand.
- Git 将 LF 替换为 CRLF基本上,这是一些愚蠢的东西,我什至更难以理解。 But at the end of the post, they linked this answered question here about git add --renormalize.
但在帖子的最后,他们将这个关于 git add --renormalize 的已回答问题链接到这里。 that fixes the issue - Git: how to renormalize line endings in all files in all revisions?
解决了这个问题 - Git:如何重新规范化所有修订版中所有文件的行尾?
So after doing all the steps above and writing some code, one should run:所以在完成上述所有步骤并编写一些代码后,应该运行:
git add --renormalize.
and then git commit -m "Message."
git commit -m "Message."
There should be no errors like previously this time, and every time you git commit
next there shouldn't be any issues (unless you edit the files in question).git commit
next 都不应该有任何问题(除非你编辑有问题的文件)。 I also changed the config autocrlf settings to input from true after reading the first article I linked.在阅读我链接的第一篇文章后,我还将配置 autocrlf 设置从 true 更改为输入。 Not sure if I should, but I did and the article I followed on how to do it can be found here - How to change line-ending settings
不确定我是否应该,但我做了,我关注的关于如何做的文章可以在这里找到 - 如何更改行尾设置
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.