繁体   English   中英

节点:模块解析失败:意外的令牌“您可能需要适当的加载器来处理此文件类型”

[英]Node: Module parse failed: Unexpected token “You may need an appropriate loader to handle this file type”

这是在我的webpack.base.conf.js中

resolve: {
            extensions: ['.js', '.vue', '.json'],
            alias: {
                'vue$': 'vue/dist/vue.esm.js',
                '@': resolve('src'),
            }
        },
        module: {
            rules: [
                {
                    test: /\.(js|vue)$/,
                    loader: 'eslint-loader',
                    enforce: 'pre',
                    include: [resolve('src'), resolve('test')],
                    options: {
                        formatter: require('eslint-friendly-formatter')
                    }
                },
                {
                    test: /\.vue$/,
                    loader: 'vue-loader',
                    options: vueLoaderConfig
                },
                {
                    test: /\.js$/,
                    loader: 'babel-loader',
                    include: [resolve('src'), resolve('test')]
                },

当我使用此行运行webpack

webpack ./src/main.js --output ./dist

这是完整的错误:

ERROR in ./src/main.js 240:36
Module parse failed: Unexpected token (240:36)
You may need an appropriate loader to handle this file type.
|                 state.connection.lastUpdate = Date.now();
|
>                 state.currencies = {...information.currenciesInfo};
|
|                 state.trends = {...information.trends};

在其他网站上,我读到它可能与webpack或某些机箱问题有关。 有人发现明显的问题吗?

我相信程序员使用了webpack3,我从头开始构建了webpack4

输入赞赏

编辑:main.js

// information = information[0];
                state.connection.lastUpdate = Date.now();

                state.currencies = {...information.currenciesInfo};

                state.trends = {...information.trends};

您需要一个插件来转换传播算子(...)。

使用https://babeljs.io/docs/en/babel-plugin-transform-object-rest-spread

暂无
暂无

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

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