[vite] Error when evaluating SSR module ...\astro.config.mjs: failed to import "@astrojs/tailwind"

前端开发Astro 237

Astro无法运行并出错

[vite] Error when evaluating SSR module ...\\astro.config.mjs: failed to import "@astrojs/tailwind"
|- Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'tailwindcss' imported from ...\\node_modules\@astrojs\tailwind\dist\index.js
    at new NodeError (node:internal/errors:372:5)
    at packageResolve (node:internal/modules/esm/resolve:954:9)
    at moduleResolve (node:internal/modules/esm/resolve:1003:20)
    at defaultResolve (node:internal/modules/esm/resolve:1218:11)
    at ESMLoader.resolve (node:internal/modules/esm/loader:580:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:294:18)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:80:40)
    at link (node:internal/modules/esm/module_job:78:36)

12:51:20 AM [astro] Unable to load ...\\astro.config.mjs

 error   Cannot find package 'tailwindcss' imported from ...\\node_modules\@astrojs\tailwind\dist\index.js
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'tailwindcss' imported from ...\\node_modules\@astrojs\tailwind\dist\index.js
    at new NodeError (node:internal/errors:372:5)
    at packageResolve (node:internal/modules/esm/resolve:954:9)
    at moduleResolve (node:internal/modules/esm/resolve:1003:20)
    at defaultResolve (node:internal/modules/esm/resolve:1218:11)
    at ESMLoader.resolve (node:internal/modules/esm/loader:580:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:294:18)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:80:40)
    at link (node:internal/modules/esm/module_job:78:36)

这时候需要安装依赖

yarn add -W tailwindcss@latest postcss@latest autoprefixer@latest

或者直接删除node_modules目录,全部重新安装。

Post Comment