繁体   English   中英

Webpack 无法在已经工作的节点 package 中编译 js

[英]Webpack unable to compile js in already working node package

我正在尝试对使用补丁包安装的节点 package 进行一些样式更改,为此我必须使用 webpack 来编译 src/ 目录中的代码以在 dist/ 中获取新代码。 当我运行 npx webpack 时,我收到以下错误:

ERROR in ./src/index.js 189:12
Module parse failed: Unexpected token (189:12)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|     render() {
|         return (
>             <div>

这个节点 package 开箱即用,我提醒你。 我不确定我在这里缺少什么。 package 除了默认配置文件之外没有任何配置文件。 这是里面的东西:

rules: [
      {
        test: /\.js$/,
        include: path.resolve(__dirname, 'src'),
        exclude: /(node_modules|bower_components|build)/,
        use: {
          loader: 'babel-loader',
          options: {
            presets: ['@babel/preset-env']
          }
        }
      },

提前致谢!

编辑:删除 node_modules & package-lock 并重新安装并不能解决问题

清理你的 node_modules 并重新安装软件包可能会有所帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM