Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/214.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Phantomjs 节点js和幻影js-找不到模块';弱';_Phantomjs - Fatal编程技术网

Phantomjs 节点js和幻影js-找不到模块';弱';

Phantomjs 节点js和幻影js-找不到模块';弱';,phantomjs,Phantomjs,我运行的是LinuxMint16'petra'64位,我第一次尝试使用'phantomjs'和NodeJS 我已经在全球安装了phantomjs: sudo npm install -g phantomjs 。。。并确认它正在运行(我通过在终端中运行“phantomjs”得到phantomjs提示) 我已经在我的节点项目中安装了节点“幻影”模块: npm install phantom 到目前为止还不错 但是,在我的应用程序代码中,一旦它尝试执行这一行: var phantom = requ

我运行的是LinuxMint16'petra'64位,我第一次尝试使用'phantomjs'和NodeJS

我已经在全球安装了phantomjs:

sudo npm install -g phantomjs
。。。并确认它正在运行(我通过在终端中运行“phantomjs”得到phantomjs提示)

我已经在我的节点项目中安装了节点“幻影”模块:

npm install phantom
到目前为止还不错

但是,在我的应用程序代码中,一旦它尝试执行这一行:

var phantom = require('phantom');
。。。程序因以下跟踪而崩溃:

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) 监听端口3000 即将实例化幻影模块。。。 module.js:333 犯错误; ^ 错误:找不到模块“弱” 在Function.Module.\u解析文件名(Module.js:331:15) 在Function.Module.\u加载(Module.js:273:25) at Module.require(Module.js:357:17) 根据需要(module.js:373:17) 在新的D(/home/joe/Documents/My Stuff/Programming/Angular.js Projects/NodeJS Messing/FreeAgentScraper/node_modules/phantom/node_modules/dnode/index.js:28:20) 在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 在Server.handler(/home/joe/Documents/My Stuff/Programming/Angular.jsprojects/NodeJS Messing/FreeAgentScraper/node_modules/phantom/node_modules/shoe/index.js:22:9) 在Server.EventEmitter.emit上(events.js:104:17) 在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) 在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) 我可以确认,项目中确实没有“弱.js”

我已运行“npm安装”以确保已安装所有依赖项


谷歌搜索没有透露任何有价值的信息。有人能提供建议吗?

您的系统中是否安装了
build essential
?因为weak是一个需要在本地编译的模块。一周前,我在Ubuntu系统中安装了build essential(
sudo apt get install build essential
),但现在当我在LinuxMint中尝试时,它给了我与您相同的错误。在
npm安装-g phantom
过程中,它警告说无法安装
弱0.3.1

你找到解决办法了吗

编辑

顺便说一句,我成功使用的系统与当前系统的关键区别在于,第一个系统是32位的,第二个系统是64位的。模块“弱”是否有任何问题阻止其安装在64位机箱上

工作解决方案

我通过以下步骤解决了这个问题:

  • sudo添加apt存储库ppa:fkrull/deadsnakes
  • sudo-apt-get-update
  • sudo apt get安装python2.6
  • sudo更新替代方案——安装/usr/bin/python/usr/bin/python2.6 20
  • python--version
    应该为您提供2.6.x。当Python版本高于2.6.x时,不会安装弱模块
  • 在此之后,请确保您的节点和npm是最新版本。我有节点v0.10.28和npm v1.4.9

    如果已安装幻影模块,请通过运行
    npm uninstall phantom
    将其删除。然后运行
    npm cache clean

    现在,分别安装弱电:
    npm安装弱电
    。如果通过,请通过运行
    npm install phantom
    安装phantom


    这应该可以解决问题。

    我在windows机器中使用node.js和phantom时遇到了同样的问题,我发现您需要在windows环境中进行一些特殊处理。npm文件是


    注意phantom.create(函数、选项、回调),这里的选项使用dnodeOpts:{weak:false}

    我也遇到了同样的问题,这段代码修复了我的问题。 幻影版本=1.9.8 幻影npm模块版本=0.8.4

    `


    `确实如此。错别字,对不起。应该是:“sudo npm安装-g phantomjs”(现在有问题更正)。当前版本的node:v0.11.14-npm:1.4.9之前的当前版本完成了上述所有操作。通过“npm安装弱”部分失败>weak@0.3.1install/home/joe/Documents/My Stuff/Programming/Angular.js Projects/NodeJS Messing/FreeAgentScraper/node_modules/weak>node gyp rebuild gyp ERR!配置错误gyp ERR!堆栈错误:无法安装节点的“pre”版本,请使用--nodedir标志代替gyp ERR!stack at install(/usr/local/lib/node_modules/npm/node_modules/node gyp/lib/install.js:66:16)嗯,我从来没有遇到过这个问题。我发现了两个与您的问题和相关的stackoverflow问题。看看他们。我想使用node.js的稳定版本而不是
    v0.11.14-pre
    可以解决这个问题。或者使用
    --nodedir
    标志。这应该是可接受的答案。为我解决了“弱”依赖性问题。
    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}
    });
    
    var phantom=require('phantom');
    phantom.create(function( ph ){  
        },{
            dnodeOpts: {
                weak: false
            },
            parameters:{
                'web-security': 'no'
            }
    });