你是如何用 Webpack 和 Babel 编译的?

问题描述

我有一个看起来像这样的包 json:

  "scripts": {
    "start": "NODE_ENV=development node node_modules/webpack/bin/webpack.js --progress  --config=node_modules/laravel-mix/setup/webpack.config.js","watch": "NODE_ENV=development node node_modules/webpack/bin/webpack.js --watch --progress  --config=node_modules/laravel-mix/setup/webpack.config.js","hot": "NODE_ENV=development webpack-dev-server --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js","production": "NODE_ENV=production node node_modules/webpack/bin/webpack.js --progress --config=node_modules/laravel-mix/setup/webpack.config.js"
  },"dependencies": {
    "postcss-custom-properties": "^11.0.0","react": "^16.14.0","react-dom": "^16.14.0","react-qr-barcode-scanner": "^1.0.6","webpack-mix": "^3.0.0"
  },"devDependencies": {
    "@babel/cli": "^7.14.8","@babel/core": "^7.14.8","@babel/plugin-proposal-class-properties": "^7.3.4","@babel/preset-env": "^7.14.8","@babel/preset-react": "^7.0.0","babel-loader": "^8.2.2","gulp-babel": "^8.0.0","import-glob": "^1.5.0","laravel-mix": "^6.0.25","postcss": "^8.3.6","sass": "^1.36.0","sass-loader": "^12.1.0","webpack": "^5.47.1","webpack-cli": "^4.0.0"
  }

我正在尝试使用 webpacksrc/qr.js 中的 javascript 文件编译为 dist/qr.js。 >

尽管在使用 npm run production 进行编译时我遇到了这个错误

enter image description here

我有几个问题:

  1. babel 怎么了?我正在使用 webpack 进行编译,webpack 是否使用 babel 进行编译?
  2. 尝试安装@babel/preset-cli 时,它说找不到 npm 包。

有人知道我在这里做错了什么吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)