0

我正在尝试使用无服务器部署我的 nuxt 应用程序,但出现错误“找不到模块 'nuxt-purgecss'”。

知道什么可以解决吗?

在我的 nuxt.config.js 下面

module.exports = {
  mode: "universal",
  /*
   ** Headers of the page
   */
  head: {
    title: process.env.APP_NAME,
    meta: [
      { charset: "utf-8" },
      { name: "viewport", content: "width=device-width, initial-scale=1" },
      {
        hid: "description",
        name: "description",
        content: process.env.npm_package_description || ""
      }
    ],
    link: [{ rel: "icon", type: "image/x-icon", href: "/favicon.ico" }]
  },
  /*
   ** Customize the progress-bar color
   */
  loading: { color: "#fff" },
  /*
   ** Global CSS
   */
  css: ["~/assets/sass/tailwind.sass"],
  /*
   ** Plugins to load before mounting the App
   */
  plugins: [
    "./plugins/global.js",
    "./plugins/mixins/responsive.js",
    "./plugins/sbkl-client.js"
  ],
  /*
   ** Nuxt.js dev-modules
   */
  buildModules: [],
  /*
   ** Nuxt.js modules
   */
  modules: [
    "@nuxtjs/axios",
    "@nuxtjs/dotenv",
    "@nuxtjs/auth",
    "portal-vue/nuxt",
    "nuxt-purgecss"
  ],
  /*
   ** Axios module configuration
   ** See https://axios.nuxtjs.org/options
   */
  axios: {
    baseURL: process.env.URL + "/api"
  },
  /*
   ** Build configuration
   */
  build: {
    /*
     ** You can extend webpack config here
     */
    extractCSS: true,
    postcss: {
      plugins: {
        tailwindcss: path.resolve(__dirname, "./tailwind.config.js")
      }
    },
    transpile: ["sbkl-client"],
    extend(config, ctx) {}
  },
  purgeCSS: {
    mode: "postcss",
    paths: ["node_modules/sbkl-client/**/*.vue", "admin.config.js"]
  }
};

我的 package.json:

{
  "dependencies": {
    "@nuxtjs/auth": "^4.9.0",
    "@nuxtjs/axios": "^5.3.6",
    "@nuxtjs/dotenv": "^1.4.0",
    "@popperjs/core": "^2.1.0",
    "nuxt-start": "^2.11.0",
    "portal-vue": "^2.1.7",
    "sbkl-client": "^1.0.1",
    "serverless-nuxt": "^1.1.1"
  },
  "devDependencies": {
    "@tailwindcss/ui": "^0.1.3",
    "node-sass": "^4.13.1",
    "nuxt": "^2.11.0",
    "nuxt-purgecss": "^0.2.1",
    "sass-loader": "^8.0.2",
    "serverless-domain-manager": "^3.3.1",
    "serverless-nuxt-plugin": "^1.1.0",
    "tailwindcss": "^1.2.0"
  }
}
4

1 回答 1

1

只需将 nuxt-purgecss 从我的 devDependencies 移动到我的依赖项,因为构建需要它。

{
  "dependencies": {
    "@nuxtjs/auth": "^4.9.0",
    "@nuxtjs/axios": "^5.3.6",
    "@nuxtjs/dotenv": "^1.4.0",
    "@popperjs/core": "^2.1.0",
    "nuxt-purgecss": "^0.2.1",
    "nuxt-start": "^2.11.0",
    "portal-vue": "^2.1.7",
    "sbkl-client": "^1.0.1",
    "serverless-nuxt": "^1.1.1"
  },
  "devDependencies": {
    "@tailwindcss/ui": "^0.1.3",
    "node-sass": "^4.13.1",
    "nuxt": "^2.11.0",
    "sass-loader": "^8.0.2",
    "serverless-domain-manager": "^3.3.1",
    "serverless-nuxt-plugin": "^1.1.0",
    "tailwindcss": "^1.2.0"
  }
}
于 2020-03-16T08:50:34.747 回答