【问题标题】:TypeError: Cannot read properties of undefined (reading 'tap')类型错误:无法读取未定义的属性(读取 \'tap\')
【发布时间】:2023-02-06 13:35:09
【问题描述】:

发生此错误时,我正在尝试安装 react-multi-carousel 库:

./node_modules/react-multi-carousel/lib/styles.css
TypeError: Cannot read properties of undefined (reading 'tap')

我认为这是因为该项目使用nextjs(只知道极端基础)。这是我的next.config 文件:

const webpack = require('webpack')
const withPlugins = require('next-compose-plugins')
const optimizedImages = require('next-optimized-images')
const withCSS = require('@zeit/next-css')
const path = require('path')

const withReactStorefront = require('react-storefront/plugins/withReactStorefront')
require('dotenv').config()

module.exports = withReactStorefront({
  target: 'serverless',
  connector: 'connector',
  webpack: config => {
    config.plugins.push(
      new webpack.optimize.LimitChunkCountPlugin({
        maxChunks: 1,
      })
    )
    return config
  },
})
const nextConfig = {
  webpack: (config, { dev }) => {

    config.module.rules.push({
      test: /\.svg$/,
      use: ['@svgr/webpack'],
    })
    
    config.plugins.push(new webpack.EnvironmentPlugin(process.env))
    config.resolve.alias['components'] = path.join(__dirname, 'components')
    config.resolve.alias['static'] = path.join(__dirname, 'static')

    return config
  },
}

module.exports = withPlugins(
  [
    [
      optimizedImages,
      {
        handleImages: ['jpeg', 'png'],
      },
    ],
    withCSS,
  ],
  nextConfig
)

此外,我正在尝试将这些样式导入名为restaurants.js 的下一页组件中。我尝试在_app.js 中导入,但它也没有用。

【问题讨论】:

  • “点击”是什么或在哪里?
  • 我不知道。每次我尝试在任何地方导入 CSS 文件时都会发生此错误。
  • 它可能与安装的包有关。尝试检查 package.json 并运行“npm i”来安装所有依赖项。然后再次运行。跟包有关。

标签: javascript reactjs next.js react-multi-carousel


【解决方案1】:

你解决这个问题了吗?我遇到了同样的麻烦。

【讨论】:

    猜你喜欢
    • 2018-04-29
    • 2022-12-08
    • 2022-12-01
    • 2022-12-21
    • 2022-12-24
    • 2022-12-25
    • 2023-01-21
    • 1970-01-01
    • 2021-12-03
    相关资源
    最近更新 更多