Question

I am trying to install phantomjs-node module on a Windows 7 (64 bit) machine. There seems to be node-gyp rebuild error while installing "weak" module.

I have followed the node-gyp windows installation steps and ensured I have python installed and its path set correctly.

I have also visual c++ and other requirements needed for node-gyp. Sadly I couldn't get the node-gyp rebuild error fixed.

I have the following installed

  • node - 0.8.14(64 bit)
  • python - 2.7.3(64 bit)
  • Microsoft Visual C++ 2010 (64 bit, also installed 32bit just in case, since 64 bit didn't help)
  • Visual Studio 2010 (Pro) and Visual Studio 2012 (express, both web and desktop)
  • Windows SDK 7.1

The error I keep getting while installing the weak module is:

C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.Cpp.InvalidPlatform.Targets(23,7): error MSB8007: The Platform for project 'weakref.vcxproj' is invalid. Platform='x64'. You may be seeing this message because you are trying to build a project without a solution file, and have specified a non-default Platform that doesn't exist for this project.

I am stuck with the above issue, having tried all the links and had all the node-gyp requirements installed correctly. Help much appreciated.

Was it helpful?

Solution 4

After much experimenting, I was able to fix the problem.

I reinstalled the windows sdk 7.1, this time I have changed the default path where the installation of sdk takes place. Earlier the sdk was by default getting installed to

C:\Program Files\Microsoft SDKs\Windows\v7.1

but after the installation was complete when I looked in C:\Program Files\Microsoft SDKs , I could not find any windows sdk, because it got installed in C:\Program Files (x86)\Microsoft SDKs\Windows folder instead. So while re-installing the windows sdk I have changed the default path which was pointing to C:\Program Files\ Microsoft SDKs to C:\Program Files (x86)\ Microsoft SDKs and that helped.

Before re-installing windows sdk make sure to uninstall all the visual c++ versions that got installed.

The weak module got installed but with a warning, which didn't cause any problem though. Hope this helps.

OTHER TIPS

I have been searching for this answer for days and the above fix didn't work for me.

The solution I found that worked like a charm is here: Cannot install node modules that require compilation on Windows 7 x64/VS2012

npm install phantom -msvs_version=2012

None of these solutions worked, or there were too many unknowns, so I needed an easier solution. What I did was use the method suggested on the https://github.com/sgentle/phantomjs-node page, where it says

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

var phantom = require('phantom');

phantom.create(function (ph) {
  ph.createPage(function (page) {
    /* the page actions */
  });
}, {
  dnodeOpts: {
    weak: false
  }
});

Thus, assuming you're on Windows (otherwise you probably wouldn't have this issue at all), just set the dnodeOpts to false, as shown above, and then end the phantom.create function. For example, if you were using the starter code:

phantom.create(function (ph) {
    ph.createPage(function (page) {
        page.open("http://www.google.com", function (status) {
          console.log("opened google? ", status);
          page.evaluate(function () { return document.title; }, function (result) {
            console.log('Page title is ' + result);
            ph.exit();
          });
        });
    });
}, {
    dnodeOpts: {
        weak: false
    }        
});

Try reinstalling windows SDK and it should fix the issue.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top