Louis Cruz
Louis Cruz

Reputation: 1673

Webpack with Phantom/Casper/Spooky: Unable to Open File

My Spooky/Casper/Phantom project was working just fine. Then I tried to involve Webpack.

When I run the program, I get:

CasperError: Can't find module node_modules/spooky/lib/bootstrap/emit
[ { file: 'phantomjs://code/bootstrap.js',
    line: 297,
    function: 'patchedRequire' } ]

My file structure is as follows:

In my index.js:

import Spooky from 'spooky';

const spooky = new Spooky({
  child: {
    transport: 'http',
    spooky_lib: 'node_modules/spooky/',
  },
  casper: {
    logLevel: 'debug',
    verbose: false
  }
}, ...);

My webpack.config.js:

const path = require('path');

module.exports = {
  context: __dirname,
  entry: './index.js',
  target: 'node',
  output: {
    path: path.join(__dirname, 'dist'),
    filename: 'index.js',
    publicPath: path.join(__dirname, 'dist')
  },
  devtool: 'source-maps',
  node: {
    __dirname: true
  },
  module: {
    rules: [
      {
        test: /\.(js)$/,
        exclude: /node_modules/,
        use: {
          loader: 'babel-loader',
        },
      }
    ]
  },
  resolve: {
    extensions: ['.js']
  }
};

Upvotes: 1

Views: 378

Answers (0)

Related Questions