webpack打包时候报错报错信息如下

在这里插入图片描述

ERROR in ./static/js/index.js
Module build failed (from ./node_modules/babelloader/lib/index.js):
TypeError: this.getOptions is not a function

报错原因使用了高版本babelloader,导致babelloaderbabelcore版本冲突,我降低之前babelloader为9版本

解决办法:降低babelloader版本执行如下命令

npm install -D babel-loader@7 babel-core babel-preset-env

package.json文件内容如下

{
  "name": "djangomall",
  "version": "0.0.0",
  "description": "djangomall app",
  "main": "index.js",
  "scripts": {
    "watch": "set NODE_OPTIONS=--openssl-legacy-provider && webpack --mode=development --progress --watch",
    "test": "echo "Error: no test specified" && exit 1"
  },
  "author": "jacky",
  "license": "ISC",
  "devDependencies": {
    "@babel/preset-react": "^7.18.6",
    "babel-core": "^4.7.16",
    "babel-loader": "^7.1.5",
    "babel-preset-env": "^1.7.0",
    "cross-env": "^7.0.2",
    "css-loader": "^4.1.1",
    "style-loader": "^1.1.2",
    "webpack": "^4.43.0",
    "webpack-bundle-tracker": "^0.4.3",
    "webpack-cli": "^3.3.11"
  },
  "dependencies": {
    "bootstrap": "^5.2.3",
    "react": "^18.3.0-next-8310854ce-20230331",
    "react-dom": "^18.3.0-next-8310854ce-20230331"
  }
}

原文地址:https://blog.csdn.net/weixin_43883625/article/details/129913007

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任

如若转载,请注明出处:http://www.7code.cn/show_34554.html

如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱suwngjj01@126.com进行投诉反馈,一经查实,立即删除

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注