当前位置:首页 » 《资源分享》 » 正文

webpack报错:Module build failed (from ./node_modules/babel-loader/lib/index.js)

5 人参与  2024年04月07日 18:25  分类 : 《资源分享》  评论

点击全文阅读


webpack打包的时候报错,报错信息如下:

在这里插入图片描述

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

报错原因:使用了高版本的babel-loader,导致babel-loader和babel-core版本冲突,我降低之前babel-loader为9版本

解决办法:降低babel-loader版本,执行如下命令

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"  }}

点击全文阅读


本文链接:http://zhangshiyu.com/post/91926.html

<< 上一篇 下一篇 >>

  • 评论(0)
  • 赞助本站

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

关于我们 | 我要投稿 | 免责申明

Copyright © 2020-2022 ZhangShiYu.com Rights Reserved.豫ICP备2022013469号-1