1

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:

  • dist/
  • index.js
  • webpack.config.js
  • ...
  • node_modules/

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']
  }
};
Louis Cruz
  • 1,703
  • 2
  • 15
  • 20
  • Did you try removing this line `spooky_lib: 'node_modules/spooky/',` ? – ickyrr Feb 10 '17 at 05:51
  • Yes, then I just get a different error. It then says: `CasperError: Can't find module node_modules/spooky/lib/../lib/bootstrap/emit` – Louis Cruz Feb 10 '17 at 05:53
  • I search a bit and found this https://github.com/SpookyJS/SpookyJS/issues/179, see if you can figure something out. – ickyrr Feb 10 '17 at 06:01
  • It has something to do with the path. You could try making the path relative like `./node_modules/spooky` – ickyrr Feb 10 '17 at 06:03
  • I've tried that too. In that case, I get `CasperError: Can't find module ./node_modules/spooky/lib/bootstrap/emit`. – Louis Cruz Feb 10 '17 at 06:05
  • It does seem that I am not finding the correct relative path. But I have no idea which context that path is relative to. I've tried several different options, but none of them take. – Louis Cruz Feb 10 '17 at 06:06
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/135347/discussion-between-ickyrr-and-louis-cruz). – ickyrr Feb 10 '17 at 06:10

0 Answers0