Node js and phantomjs - Cannot find module 'weak'

user2209634

I am running on Linux Mint 16 'petra' 64 bit, and I am trying to use 'phantomjs' for the first time, together with node js.

I have installed phantomjs globally:

sudo npm install -g phantomjs

... and confirmed that it is running (I get the phantomjs prompt by running "phantomjs" in terminal)

and I have installed the node 'phantom' module within my node project:

npm install phantom

So far so good.

However, within my application code, as soon as it attempts to execute this line:

var phantom = require('phantom');

... the program crashes with the following trace:

Listening on port 3000
about to instantiate phantom module...
module.js:333
    throw err;
          ^
Error: Cannot find module 'weak'
    at Function.Module._resolveFilename (module.js:331:15)
    at Function.Module._load (module.js:273:25)
    at Module.require (module.js:357:17)
    at require (module.js:373:17)
    at new D (/home/joe/Documents/My Stuff/Programming/Angular.js Projects/NodeJS Messing/FreeAgentScraper/node_modules/phantom/node_modules/dnode/index.js:28:20)
    at module.exports (/home/joe/Documents/My Stuff/Programming/Angular.js Projects/NodeJS Messing/FreeAgentScraper/node_modules/phantom/node_modules/dnode/index.js:8:12)
    at /home/joe/Documents/My Stuff/Programming/Angular.js Projects/NodeJS Messing/FreeAgentScraper/node_modules/phantom/phantom.js:135:13
    at Server.handler (/home/joe/Documents/My Stuff/Programming/Angular.js Projects/NodeJS Messing/FreeAgentScraper/node_modules/phantom/node_modules/shoe/index.js:22:9)
    at Server.EventEmitter.emit (events.js:104:17)
    at App.emit (/home/joe/Documents/My Stuff/Programming/Angular.js Projects/NodeJS Messing/FreeAgentScraper/node_modules/phantom/node_modules/shoe/node_modules/sockjs/lib/sockjs.js:182:27)
    at Session.emit_open (/home/joe/Documents/My Stuff/Programming/Angular.js Projects/NodeJS Messing/FreeAgentScraper/node_modules/phantom/node_modules/shoe/node_modules/sockjs/lib/transport.js:107:23)

I can confirm that indeed there is no 'weak.js' anywhere in the project.

I have run 'npm install' to ensure that all dependencies have been installed.

Google search hasn't revealed anything worthwhile. Can anyone offer any advice?

user2500299

I had the same issue using node.js and phantom in a windows machine, what I found that you need some special treatment on the windows enviroment. the npm document is here.

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

notice phantom.create(function, options, callback), and here options uses dnodeOpts: {weak: false}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Node js and phantomjs - Cannot find module 'weak'

From Dev

Node.js: Cannot find module 'chai'

From Dev

Node.js cannot find an installed module

From Dev

cannot find node.js module

From Dev

Cannot find module './*.env' node js

From Java

Node.js Error: Cannot find module express

From Dev

Seriously debugging node.js 'Cannot find module xyz/abcd'

From Dev

Node.js Error: Cannot find module 'request'

From Dev

node.js cannot find a module in the same folder

From Dev

node.js Cannot find module './lib/compat'

From Dev

"Error: Cannot find module 'pkginfo'" - node js app deploying to heroku

From Dev

Cannot find module 'extend' Lambda node JS in AWS

From Dev

How to fix Node.js error: Cannot find module 'immer'

From Dev

Node.js - Error: Cannot find module 'config/chgpass'

From Dev

Seriously debugging node.js 'Cannot find module xyz/abcd'

From Dev

Error: Cannot find module 'html' with Node.JS and Express

From Dev

Node.js error: Cannot find module 'firebase/storage'

From Dev

Node.js Express Error: Cannot find module

From Dev

node-gyp rebuild failed while installing "weak" module on windows 7 for phantomjs

From Dev

node-gyp rebuild failed while installing "weak" module on windows 7 for phantomjs

From Dev

Node.js - "Cannot find module", when the module call other module

From Dev

Cannot find module 'webpage' when using PhantomJS in MeteorJS

From Dev

Cannot find module 'casper' when invoking through PhantomJS

From Dev

Node.JS cannot find module 'xml2js' (Windows)

From Java

ERROR in Cannot find module 'node-sass'

From Dev

Heroku + Node: Cannot find module error

From Dev

Cannot find module 'node-gcm'

From Dev

Cannot find module 'node_modules/formidable'

From Dev

Cannot find module 'node-gcm'

Related Related

  1. 1

    Node js and phantomjs - Cannot find module 'weak'

  2. 2

    Node.js: Cannot find module 'chai'

  3. 3

    Node.js cannot find an installed module

  4. 4

    cannot find node.js module

  5. 5

    Cannot find module './*.env' node js

  6. 6

    Node.js Error: Cannot find module express

  7. 7

    Seriously debugging node.js 'Cannot find module xyz/abcd'

  8. 8

    Node.js Error: Cannot find module 'request'

  9. 9

    node.js cannot find a module in the same folder

  10. 10

    node.js Cannot find module './lib/compat'

  11. 11

    "Error: Cannot find module 'pkginfo'" - node js app deploying to heroku

  12. 12

    Cannot find module 'extend' Lambda node JS in AWS

  13. 13

    How to fix Node.js error: Cannot find module 'immer'

  14. 14

    Node.js - Error: Cannot find module 'config/chgpass'

  15. 15

    Seriously debugging node.js 'Cannot find module xyz/abcd'

  16. 16

    Error: Cannot find module 'html' with Node.JS and Express

  17. 17

    Node.js error: Cannot find module 'firebase/storage'

  18. 18

    Node.js Express Error: Cannot find module

  19. 19

    node-gyp rebuild failed while installing "weak" module on windows 7 for phantomjs

  20. 20

    node-gyp rebuild failed while installing "weak" module on windows 7 for phantomjs

  21. 21

    Node.js - "Cannot find module", when the module call other module

  22. 22

    Cannot find module 'webpage' when using PhantomJS in MeteorJS

  23. 23

    Cannot find module 'casper' when invoking through PhantomJS

  24. 24

    Node.JS cannot find module 'xml2js' (Windows)

  25. 25

    ERROR in Cannot find module 'node-sass'

  26. 26

    Heroku + Node: Cannot find module error

  27. 27

    Cannot find module 'node-gcm'

  28. 28

    Cannot find module 'node_modules/formidable'

  29. 29

    Cannot find module 'node-gcm'

HotTag

Archive