phantomjs在访问aws-sdk时找不到节点模块“encryption”

我有一个应用程序正在使用幻影js和nodejs应用程序。 我正在使用节点应用程序中的几个节点模块,这是通过幻像js运行。 我需要使用亚马逊节点aws-sdk。 我安装了它

npm install aws-sdk 

该节点的应用程序能够find一旦我这样做

 var AWS = require('aws-sdk'); 

但它开始提示其他本地节点js模块的错误,其中三个具体是“encryption”,“定时器”,“path”。 我检查了/ usr / lib / nodejs文件夹和那些在那里,所以如何phantomjs节点应用程序无法find它们? 具体的错误

 Error: Cannot find module 'crypto' phantomjs://platform/bootstrap.js:299 in require phantomjs://platform/bootstrap.js:263 in require phantomjs://platform/util.js:4 TypeError: undefined is not a function (evaluating 'AWS.util.update') phantomjs://platform/core.js:16 Error: Cannot find module 'path' phantomjs://platform/bootstrap.js:299 in require phantomjs://platform/bootstrap.js:263 in require phantomjs://platform/api_loader.js:3 Error: Cannot find module 'events' phantomjs://platform/bootstrap.js:299 in require phantomjs://platform/bootstrap.js:263 in require phantomjs://platform/xml2js.js:12 phantomjs://platform/xml2js.js:538 TypeError: undefined is not an object (evaluating 'AWS.XML.Parser = require('./xml/node_parser')') 

它工作正常,如果我直接去节点壳,并要求('aws-sdk')。 我像这样从phantomjs运行节点应用程序

 phantomjs test.js 

要么

 /usr/bin/phantomjs test.js 

它只是不适用于phantomjs,任何想法和帮助,将不胜感激在这里。

PhantomJS与node.js不兼容。

当你运行它像

 /usr/bin/phantomjs test.js 

你在PhantomJS里面运行一个脚本。

如果你想从PhantomJS启动一个node.js应用程序,你可以使用exec或spawn方法来实现它,看到这个答案