NodeJS React:Tailwind CSS with DaisyUI错误:Object.hasOwn不是一个函数

ozxc1zmp  于 12个月前  发布在  Node.js
关注(0)|答案(1)|浏览(156)

我的Tailwind CSS Intellisense扩展在输出中给了我这个错误:[Error - 7:41:37 PM] Tailwind CSS:Object.hasOwn is not a function TypeError:Object.hasOwn is not a function
Tailwind配置文件:

/** @type {import('tailwindcss').Config} */
module.exports = {
  content: [
    "./src/pages/**/*.{js,ts,jsx,tsx,mdx}",
    "./src/components/**/*.{js,ts,jsx,tsx,mdx}",
    "./src/app/**/*.{js,ts,jsx,tsx,mdx}",
  ],
  plugins: [require('daisyui')],
  daisyui: {
    themes: [
      {
        lightTheme: {
          primary: "#f4aa3a",
          secondary: "#f4f4a1",
          accent: "#1be885",
          neutral: "#272136",
          "base-100": "#ffffff",
          info: "#778ad4",
          success: "#23b893",
          warning: "#f79926",
          error: "#ea535a",
          body: {
            "background-color": "#e3e6e6",
          },
        },
      },
    ],
  },
};

字符串
package.json:

{
  "name": "nextjs-ecommerce",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "@auth/prisma-adapter": "^1.0.3",
    "@prisma/client": "^5.4.2",
    "daisyui": "^3.9.2",
    "eslint-config-prettier": "^9.0.0",
    "next": "13.5.4",
    "next-auth": "^4.23.2",
    "prettier": "^3.0.3",
    "prettier-plugin-tailwindcss": "^0.5.6",
    "prisma": "^5.4.2",
    "react": "^18",
    "react-dom": "^18",
    "zod": "^3.22.4"
  },
  "devDependencies": {
    "@types/node": "^20",
    "@types/react": "^18",
    "@types/react-dom": "^18",
    "autoprefixer": "^10",
    "eslint": "^8",
    "eslint-config-next": "13.5.4",
    "postcss": "^8",
    "tailwindcss": "^3",
    "typescript": "^5"
  }
}


我尝试的事情:
1.重新安装Tailwind CSS Intellisense扩展
1.将NodeJS从V18.16.0升级到20.9.0(根据文档,两个版本都远远超过DaisyUI的要求)
1.完全重新安装NodeJS
1.禁用Tailwind CSS Intellisense扩展并重新启用它
1.重新启动VS代码
1.删除所有daisyui包并使用npm重新安装它们
如果我从插件中删除“require(daisyui)”,一切都正常。
如果你能帮忙的话,我将不胜感激。

j7dteeu8

j7dteeu81#

重新安装VS代码并从头开始设置开发环境后,问题得到解决。

相关问题