0

I'm trying to execute this code but I don't know why it shows error. I'm new at Nodejs, so i attach the code and ss of error please help how to fix this

var webshot = require('webshot');
var flatiron = require('flatiron');

var app = flatiron.app;

app.use(flatiron.plugins.http);

app.router.get('/getImage', function() {
      var self = this;
      var requestUrl = this.req.headers['head'];
      console.log(requestUrl); 
      webshot(requestUrl, function(err, renderStream) {
        renderStream.pipe(self.res);
      });
});

app.start(3000,"IP Address");

console.log('Starting Node Server');

error =

Debugger attached.
Waiting for the debugger to disconnect...
fs.js:45
} = primordials;
    ^

ReferenceError: primordials is not defined
    at fs.js:45:5
    at req_ (c:\Users\HOME\Desktop\NodeScripts\node_modules\natives\index.js:143:24)
    at Object.req [as require] (c:\Users\HOME\Desktop\NodeScripts\node_modules\natives\index.js:55:10)
    at Object.<anonymous> (c:\Users\HOME\Desktop\NodeScripts\node_modules\graceful-fs\fs.js:1:37)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
Process exited with code 1

1 Answers1

0

First note encountering this kind of issue is not common when using Node.js. The packages webshot and flatiron haven't been maintained for 5 years at the time of writing, which is the primary reason they're incompatible with the current version of Node.js.

Typically when this error is encountered, you either need to use different packages, or downgrade to an older version of Node.js. According to the comments here, you should be able to downgrade to Node.js v11, but I highly suggest exploring more recently maintained packages like capture-website and express in order to stick with the latest LTS version of Node.js.

Patrick Roberts
  • 49,224
  • 10
  • 102
  • 153