首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >找不到模块:错误:无法解析'babel-loader‘

找不到模块:错误:无法解析'babel-loader‘
EN

Stack Overflow用户
提问于 2018-06-04 19:48:18
回答 2查看 3.6K关注 0票数 0

我刚刚把我的web pack从2.x升级到了4.x。通过执行npm install,我得到了以下错误

代码语言:javascript
复制
Module not found: Error: Can't resolve 'babel-loader' 

github thread之后,我在webpack.config.json中添加了以下行

代码语言:javascript
复制
 resolveLoader: {   root: path.join(__dirname, 'node_modules') }

但是我得到了以下错误,

代码语言:javascript
复制
Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration.resolveLoader has an unknown property 'modulesDirectories'. These properties are valid: object { alias?, aliasFields?, cachePredicate?, descriptionFiles?, enforceExtension?, enforceModuleExtension?, extensions?, fileSystem?, mainFields?, mainFiles?, moduleExtensions?, modules?, plugins?, resolver?, symlinks?, unsafeCache?, useSyncFileSystemCalls? }

babel-loader版本是7.1.4。Webpack升级已经引入了这个错误。对此有什么建议吗?

EN

回答 2

Stack Overflow用户

发布于 2018-06-04 19:51:02

你不是要安装这个"babel-loader“https://www.npmjs.com/package/babel-loader吗?

代码语言:javascript
复制
module: {
    rules: [{
        test: /\.jsx?$/,
        include: [
            path.resolve(__dirname, 'src/js'),
        ],
        loader: "babel-loader",
        options: {
            presets: ["es2015"],
            plugins: [
                ["babel-plugin-root-import", {
                    "rootPathSuffix": "src/js"
                }],
                [
                    "transform-runtime", {
                        "helpers": false,
                        "polyfill": false,
                        "regenerator": true,
                        "moduleName": "babel-runtime"
                    }
                ],
                "transform-object-assign", "transform-function-bind"
            ]
        },
        // options for the loader
    }}
票数 0
EN

Stack Overflow用户

发布于 2020-04-16 15:07:49

只需安装模块即可:

npm install babel-loader

yarn add babel-loader

我通过运行上面的命令解决了这个问题。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50679906

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档