a blog for those who code

Thursday 31 December 2015

How to solve Cannot find module weak in Nodejs

In this post we will be discussing about how to solve "Cannot find module weak" while using phantom module in Node.js. Lets say you have installed phantom module using npm install phantom and you are trying to use it inside your code, you will get this error in Windows.


Phantom will use dnode with weak module by default. It means that you need to setup node-gyp with Microsoft VS2010 or VS2012 to make it work. But it is a very huge installation on Windows. If you do not want to install node-gyp with Visual Studio then you can disable weak.

dnodeOpts property could help you to control dnode settings, so you could disable weak by setting it false to avoid complicated installations as shown below.

var ph = require('phantom');

ph.create(function (p) {
  p.createPage(function (page) {
    // Page Actions
  });
}, {
  dnodeOpts: {
    weak: false
  }
});

Please Like and Share the CodingDefined.com Blog, if you find it interesting and helpful.

No comments:

Post a Comment