Nuxt:找不到模块'@tailwindcss/jit'

Posted

技术标签:

【中文标题】Nuxt:找不到模块\'@tailwindcss/jit\'【英文标题】:Nuxt: Cannot find module '@tailwindcss/jit'Nuxt:找不到模块'@tailwindcss/jit' 【发布时间】:2021-08-02 16:10:09 【问题描述】:

当我运行npm run dev时,找不到模块@tailwindcss/jit,我应该如何解决?

$ npm run dev

> myproject@1.0.0 dev
> nuxt


 WARN  webpack@5.37.0 is installed but ^4.46.0 is expected                                                                                                                                                                                      11:44:40

ℹ Merging Tailwind config from ~/tailwind.config.js                                                                                                                                                                            nuxt:tailwindcss 11:44:40
ℹ Parsed 4 files in 0,6 seconds                                                                                                                                                                                                   @nuxt/content 11:44:41

   ╭───────────────────────────────────────────────────────╮
   │                                                       │
   │   Nuxt @ v2.15.5                                      │
   │                                                       │
   │   ▸ Environment: development                          │
   │   ▸ Rendering:   server-side                          │
   │   ▸ Target:      server                               │
   │                                                       │
   │   Listening: http://localhost:3003/                   │
   │                                                       │
   │   Tailwind Viewer: http://localhost:3003/_tailwind/   │
   │                                                       │
   ╰───────────────────────────────────────────────────────╯

ℹ Preparing project for development                                                                                                                                                                                                             11:44:43
ℹ Initial build may take a while                                                                                                                                                                                                                11:44:43
ℹ Tailwind JIT activated                                                                                                                                                                                                       nuxt:tailwindcss 11:44:43
ℹ Discovered Components: .nuxt/components/readme.md                                                                                                                                                                                             11:44:43
✔ Builder initialized                                                                                                                                                                                                                           11:44:43
✔ Nuxt files generated                                                                                                                                                                                                                          11:44:43

 ERROR  Cannot find module '@tailwindcss/jit'                                                                                                                                                                                                   11:44:43
Require stack:
- /Users/me/myproject/node_modules/@nuxt/core/dist/core.js

  Require stack:
  - node_modules/@nuxt/core/dist/core.js
  at Function.Module._resolveFilename (internal/modules/cjs/loader.js:885:15)
  at Function.resolve (internal/modules/cjs/helpers.js:94:19)
  at m (node_modules/jiti/dist/jiti.js:1:52899)
  at Resolver.f [as _require] (node_modules/jiti/dist/jiti.js:1:53712)
  at Resolver.requireModule (node_modules/@nuxt/core/dist/core.js:381:29)
  at node_modules/@nuxt/webpack/dist/webpack.js:792:58
  at Array.map (<anonymous>)
  at PostcssConfig.loadPlugins (node_modules/@nuxt/webpack/dist/webpack.js:791:10)
  at PostcssConfig.config (node_modules/@nuxt/webpack/dist/webpack.js:830:14)
  at StyleLoader.postcss (node_modules/@nuxt/webpack/dist/webpack.js:909:39)
  at StyleLoader.apply (node_modules/@nuxt/webpack/dist/webpack.js:969:12)
  at WebpackClientConfig.rules (node_modules/@nuxt/webpack/dist/webpack.js:1357:28)
  at WebpackClientConfig.config (node_modules/@nuxt/webpack/dist/webpack.js:1537:21)
  at WebpackClientConfig.config (node_modules/@nuxt/webpack/dist/webpack.js:1708:26)
  at WebpackBundler.getWebpackConfig (node_modules/@nuxt/webpack/dist/webpack.js:2016:19)
  at WebpackBundler.build (node_modules/@nuxt/webpack/dist/webpack.js:2023:12)

tailwind.config.js:

module.exports = 
  prefix: 'tw-',
  purge: [],
  darkMode: false, // or 'media' or 'class'
  theme: 
    extend: ,
  ,
  variants: 
    extend: ,
  ,
  plugins: [],

【问题讨论】:

你能分享你的package.json吗? 【参考方案1】:nuxt.config.js 中删除jit: truemode: 'jit'添加到tailwind.config.js
module.exports = 
    mode: 'jit'

source

虽然它可能没有链接到 TailwindCSS,但我还必须在修复后清理一个节点模块:

npm uninstall @nuxtjs/eslint-module
rm -rf node_modules package-lock.json
npm install

source

【讨论】:

@nuxtjs/eslint-module 与 TailwindCSS 有什么关系? @kissu 我没有说它是链接的,只是我必须修复它,以防有人遇到同样的问题。我会编辑我的答案。

以上是关于Nuxt:找不到模块'@tailwindcss/jit'的主要内容,如果未能解决你的问题,请参考以下文章

NUXT:找不到模块:错误:无法解析“fs”

使用 Jest 测试 NUXT.js 和 Vue.js 应用程序。获取“在 mapState() 中找不到 [vuex] 模块命名空间”和“[vuex] 未知操作类型”

将 Nuxt 模块放入 Storybook

Nuxt.js:消息:“找不到此页面”(nuxt-i18n)

“找不到命令:create-nuxt-app”有啥问题

Strapi / Nuxt - 找不到自定义路线