如何修复“模块解析失败:(...默认值,...选项)意外的令牌”错误? Webpack

我正在创建浏览器扩展程序,并且正在使用pageres对其进行截图。为什么Webpack不起作用?

当我将此"boilerplate"捆绑在一起时,它可以工作,但是由于我添加了require('pageres'),因此会引发错误:

ERROR in ./~/make-dir/index.js
Module parse failed: C:\Users\<user>\Desktop\webpack-modules2\node_modules\make-dir\index.js Unexpected token (42:2)
You may need an appropriate loader to handle this file type.
|       checkPath(input);
|       options = {
|               ...defaults,|               ...options
|       };
 @ ./~/pageres/dist/index.js 16:16-35
 @ ./background_scripts/background.js

ERROR in ./~/pageres/~/capture-website/index.js
Module parse failed: C:\Users\<user>\Desktop\webpack-modules2\node_modules\pageres\node_modules\capture-website\index.js Unexpected token (145:2)
You may need an appropriate loader to handle this file type.
|               launchOptions: {},|               _keepAlive: false,|               ...options
|       };
|
 @ ./~/pageres/dist/index.js 17:23-49
 @ ./background_scripts/background.js

我尝试删除了这些“ ...选项,...默认值”行,但错误翻了一番。

这里是 webpack.config.js

const path = require("path");

module.exports = {
    entry: {
        background_scripts: "./background_scripts/background.js",popup: "./popup/left-pad.js"
    },output: {
        path: path.resolve(__dirname,"addon"),filename: "[name]/index.js"
    },node: {
        fs: "empty"
    }
};

background.js

const Pageres = require('pageres');

var pageres = new Pageres({delay: 2})
        .src(window.location.href,['1920x1080'])
        .src('data:text/html,<h1>Awesome!</h1>',['1024x768'])
        .dest('screenshots')
        .run();

mingtianwen 回答:如何修复“模块解析失败:(...默认值,...选项)意外的令牌”错误? Webpack

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3127982.html

大家都在问