当前位置: 首页 > 知识库问答 >
问题:

webpack带有样式加载器的bug

柳均
2023-03-14

我只想导入一个css文件(导入'./index.css'),但样式加载器抛出一个错误:

InjectStylesintoStyletag.js:74未捕获的范围错误:addModulesToDom(InjectStylesintoStyletag.js:74)的数组长度无效,位于./node_modules/style-loader/dist/runtime/InjectStylesintoStyletag.js.module.exports(InjectStylesintoStyletag.js:227)的对象../app/components/editor/index.css(index.css?033a:16)的webpack_require(bootstrap:726)的fn(

我不知道该如何处理,而我的package.json:

{
  "name": "webpack-learn",
  "version": "1.0.0",
  "description": "webpack config lear",
  "main": "app/index.js",
  "scripts": {
    "test": "I don't know what this property means.",
    "build": "webpack --config build/webpack.prod.js",
    "dev": "webpack-dev-server --config build/webpack.dev.js"
  },
  "keywords": [
    "react",
    "typescript",
    "frontend",
    "blog",
    "project",
    "component"
  ],
  "author": "xuwentao93",
  "license": "ISC",
  "devDependencies": {
    "@babel/core": "^7.7.7",
    "@babel/preset-env": "^7.7.7",
    "@babel/preset-react": "^7.7.4",
    "@typescript-eslint/eslint-plugin": "^2.13.0",
    "@typescript-eslint/parser": "^2.13.0",
    "babel-eslint": "^10.0.3",
    "babel-loader": "^8.0.6",
    "clean-webpack-plugin": "^2.0.2",
    "css-loader": "^3.4.0",
    "cssnano": "^4.1.10",
    "eslint": "^6.8.0",
    "eslint-config-airbnb": "^18.0.1",
    "eslint-loader": "^3.0.3",
    "eslint-plugin-import": "^2.19.1",
    "eslint-plugin-jsx-a11y": "^6.2.3",
    "eslint-plugin-react": "^7.17.0",
    "file-loader": "^5.0.2",
    "friendly-errors-webpack-plugin": "^1.7.0",
    "hard-source-webpack-plugin": "^0.13.1",
    "html-webpack-plugin": "^3.2.0",
    "less": "^3.10.3",
    "less-loader": "^5.0.0",
    "mini-css-extract-plugin": "^0.9.0",
    "optimize-css-assets-webpack-plugin": "^5.0.3",
    "speed-measure-webpack-plugin": "^1.3.1",
    "style-loader": "^1.1.1",
    "thread-loader": "^2.1.3",
    "ts-loader": "^6.2.1",
    "typescript": "^3.7.4",
    "webpack": "^4.41.4",
    "webpack-cli": "^3.3.10",
    "webpack-dev-server": "^3.10.1",
    "webpack-merge": "^4.2.2"
  },
  "dependencies": {
    "react": "^16.12.0",
    "react-dom": "^16.12.0",
    "react-redux": "^7.1.3",
    "react-router": "^5.1.2",
    "react-router-dom": "^5.1.2",
    "redux": "^4.0.4"
  }
}

有人能帮我吗?

共有1个答案

杨利
2023-03-14

我知道为什么问题会出现在我的项目中。当我在学习webpack的时候,我使用image-webpack-loader来缩小图像,但是它没有起作用。所以我在我的package.json中删除它并运行'yarn',然后出现了这个错误。我使用git返回我的最后一个视图,然后删除我的node_modules并再次运行'yarn',问题就解决了。但我仍然很困惑为什么样式加载器会有这个错误...

 类似资料:
  • 下面是我的整个: 将感谢帮助调试这个。

  • 我试图让在Docker容器中运行,然后通过NGINX主机访问它。初始的加载,但无法连接到开发服务器的Web套接字连接。 VM47:35到“ws://example.com/sockjs-node/834/izehemiu/WebSocket”的WebSocket连接失败:WebSocket握手过程中出错:意外响应代码:400 我使用以下配置。

  • 问题内容: 如果这是完全相同的内容,请纠正我,我知道这个话题经常被讨论,但是找不到确切的答案。 问题: 在MVC Web应用程序中处理Hibernate对象的最佳实用解决方案是什么? 细节: 我正在使用Hibernate,并希望在可能的情况下利用延迟加载。 我正在使用MVC风格的webapp。 我讨厌获得延迟加载初始化异常。 我讨厌不得不在事务之间重新连接Hibernate对象。 选项: 渴望装载

  • 问题内容: 好的,我已经搜索了高低位,但是无法可靠地确定Webpack是否可行。 https://github.com/webpack/webpack/tree/master/examples/require.context 似乎表明可以将字符串传递给函数并加载模块… 但是我的尝试没有用:webpack.config.js server.js modules /模块中名为test.js的模块 但是

  • 我试图将一个典型的HTML站点迁移到一个“轻”的React应用程序。因此,我安装了React而没有。 项目的目录结构如下所示: webpack.config.js SRC index.js CSS style.css pGrooveRunners.ttf 我该怎么解决这个?

  • 本文向大家介绍浅谈webpack对样式的处理,包括了浅谈webpack对样式的处理的使用技巧和注意事项,需要的朋友参考一下 本文介绍了webpack对样式的处理,分享给大家,具体如下: 我们可以在js中引入样式文件 这时我们便需要引入相应的webpack loader来帮助我们解析这段代码。 css-loader搭配style-loader 首先,我们可以引入css-loader和style-lo