[英]Problem with babel and tailwindcss in Next.js: Cannot find module 'xwind/babel'
I installed tailwindcss inside of my Next.js application.我在我的 Next.js 应用程序中安装了 tailwindcss。 This was the error message that I received
这是我收到的错误消息
error - ./node_modules/next/dist/client/dev/amp-dev.js
Error: Cannot find module 'xwind/babel'
This is how I installed the Next.js application:这就是我安装 Next.js 应用程序的方式:
npx create-next-app -e with-tailwindcss ./
These are the dependencies I installed:这些是我安装的依赖项:
npm install graphql graphql-request html-react-parser moment react-multi-carousel sass
Happened to me as well just few minutes ago.几分钟前也发生在我身上。 Not sure if that is the same case for you.
不知道这对你来说是否一样。 It created for me
components
folder, .babelrc file and js files in pages folder.它为我在 pages 文件夹中创建了
components
文件夹、.babelrc 文件和 js 文件。 Not sure if that is your case, but that's what happened to me.不确定这是否是你的情况,但这就是发生在我身上的事情。 In case just follow with solution below.
如果只是按照下面的解决方案。
Remove .bablerc
file and components
folder along with js files in pages
folder.删除
.bablerc
文件和components
文件夹以及pages
文件夹中的 js 文件。
This is strange because if you look at the repository of Next.js example with-tailwindcss
.这很奇怪,因为如果您查看 Next.js 示例
with-tailwindcss
tailwindcss 的存储库。 It doesn't have those.它没有这些。 Not sure how that happened.
不知道那是怎么发生的。 We can elaborate more in the comments.
我们可以在评论中详细说明。
Also plugin for babel xwind/babel
does have dependency check to allow only tailwindcss
version <2. babel
xwind/babel
的插件也有依赖检查,只允许tailwindcss
版本 <2。 There is an issue for that.有一个问题。 In my opinion this repo is unmaintained and will either get forked and replaced as a main for npm package or something similar.
在我看来,这个 repo 是无人维护的,并且会被分叉和替换为 npm package 或类似的东西的主库。
The create-next-app is installing with-tailwind-emotion
template instead of with-tailwind
for some reason.出于某种原因,create-next-app 正在安装
with-tailwind-emotion
模板而不是with-tailwind
。
For now, a good way is to create a normal typescript template with create-next-app and add tailwind manually.目前,一个好的方法是使用 create-next-app 创建一个普通的 typescript 模板并手动添加 tailwind。
So your steps would be:所以你的步骤是:
Step 1: without typescript:第 1 步:没有 typescript:
npx create-next-app ./
or with typescript:或使用 typescript:
npx create-next-app --ts ./
Step 2:第2步:
Docs to install tailwind with next.js: https://tailwindcss.com/docs/guides/nextjs使用 next.js 安装顺风的文档: https://tailwindcss.com/docs/guides/nextjs
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.