简体   繁体   English

错误:找不到模块“tailwindcss”(Next.js 应用程序)

[英]Error: Cannot find module 'tailwindcss' (Next.js application)

I recently updated my Node Package Manager in accordance with this post.我最近根据这篇文章更新了我的节点 Package 管理器。 However, now when I create a new Next.js app and run it using npm run dev , I get the following error:但是,现在当我创建一个新的 Next.js 应用程序并使用npm run dev运行它时,我收到以下错误:

error - ./node_modules/next/dist/build/webpack/loaders/css-loader/src/index.js??ruleSet[1].rules[2].oneOf[8].use[1]!./node_modules/next/dist/build/webpack/loaders/postcss-loader/src/index.js??ruleSet[1].rules[2].oneOf[8].use[2]!./styles/globals.css
Error: Cannot find module 'tailwindcss'
Require stack:
- E:\Code\testing\node_modules\next\dist\build\webpack\config\blocks\css\plugins.js
- E:\Code\testing\node_modules\next\dist\build\webpack\config\blocks\css\index.js
- E:\Code\testing\node_modules\next\dist\build\webpack\config\index.js
- E:\Code\testing\node_modules\next\dist\build\webpack-config.js
- E:\Code\testing\node_modules\next\dist\server\dev\hot-reloader.js
- E:\Code\testing\node_modules\next\dist\server\dev\next-dev-server.js
- E:\Code\testing\node_modules\next\dist\server\next.js
- E:\Code\testing\node_modules\next\dist\server\lib\start-server.js
- E:\Code\testing\node_modules\next\dist\cli\next-dev.js
- E:\Code\testing\node_modules\next\dist\bin\next
    at Array.map (<anonymous>)

What is causing the error and how do I fix it?是什么导致了错误,我该如何解决? I don't want to build my project using TailwindCSS and hence, do not want to install it.我不想使用 TailwindCSS 构建我的项目,因此也不想安装它。

Edit: I had run the npm install -D tailwindcss@latest postcss@latest autoprefixer@latest command previously to fix the error.编辑:我之前运行了npm install -D tailwindcss@latest postcss@latest autoprefixer@latest命令来修复错误。 It didn't help.它没有帮助。 I tried uninstalling it and that didn't help either.我尝试卸载它,但也没有帮助。

Remove the node_modules and .next folders and follow the guide here: https://tailwindcss.com/docs/guides/nextjs删除node_modules.next文件夹并按照此处的指南进行操作: https://tailwindcss.com/docs/guides/nextjs

This post fixed my error. 这篇文章修正了我的错误。 I had a postcss.config.js file in the parent directory that I hadn't noticed.我在父目录中有一个我没有注意到的 postcss.config.js 文件。 All my Next.js projects were created in a sub-directory and hence, the oversight.我所有的 Next.js 项目都是在子目录中创建的,因此是疏忽的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM