首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >警告:找不到PhantomJS

警告:找不到PhantomJS
EN

Stack Overflow用户
提问于 2013-08-13 19:59:50
回答 3查看 71.1K关注 0票数 19

我已经在debian 6上安装了nodejs 0.10.15。

代码语言:javascript
复制
sudo npm install grunt-cli -g

我还在本地测试目录中执行了necessary (将必要的依赖项下载到node_modules目录),其中包含以下package.json文件:

代码语言:javascript
复制
{
  "name": "sample-name",
  "version": "1.4.0",
  "devDependencies": {
    "grunt": "~0.4.1",
    "grunt-contrib-qunit": ">0.0.0",
    "grunt-qunit-istanbul": ">0.0.0"
  }
}

以下是安装幻影is时的输出:

代码语言:javascript
复制
...
Writing location.js file
Done. Phantomjs binary available at /home/myuser/Test/node_modules/grunt-contrib-qunit/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/lib/phantom/bin/phantomjs
Done. Phantomjs binary available at /home/myuser/Test/node_modules/grunt-qunit-istanbul/node_modules/grunt-lib-phantomjs-istanbul/node_modules/phantomjs/lib/phantom/bin/phantomjs
grunt@0.4.1 node_modules/grunt
├── which@1.0.5
...

但是,当我从测试dir运行grunt测试时,我得到:

代码语言:javascript
复制
Running PhantomJS...ERROR
>> In order for this task to work properly, PhantomJS must be installed locally
>> via NPM. If you're seeing this message, generally that means the NPM install
>> has failed. Please submit an issue providing as much detail as possible at:
>> https://github.com/gruntjs/grunt-lib-phantomjs/issues
Warning: PhantomJS not found. Use --force to continue.

如果我运行安装在前面指定位置的幻影If脚本,就会得到退出代码127 (指示问题路径:http://tldp.org/LDP/abs/html/exitcodes.html)。如果我禁止使用幻影bash脚本,它看起来如下所示:

代码语言:javascript
复制
#!/usr/bin/env node

var path = require('path')
var spawn = require('child_process').spawn

var binPath = require(path.join(__dirname, '..', 'lib', 'phantomjs')).path

var args = process.argv.slice(2)

// For Node 0.6 compatibility, pipe the streams manually, instead of using
// `{ stdio: 'inherit' }`.
var cp = spawn(binPath, args)
cp.stdout.pipe(process.stdout)
cp.stderr.pipe(process.stderr)
cp.on('exit', process.exit)

process.on('SIGTERM', function() {
  cp.kill('SIGTERM')
  process.exit(1)
})

据我所知,这意味着幻影在节点内执行。如果启动节点,输入路径var,就会得到:

代码语言:javascript
复制
:~$ env node
> var path = require('path')
undefined
> 

(我理解为默认行为:node.js displays "undefined" on the console)

有进一步调试此问题的建议吗?

EN

回答 3

Stack Overflow用户

发布于 2013-08-14 06:21:28

试着跑

npm uninstall phantomjs

然后跑

npm install phantomjs -g

这应该确保幻影安装在命令行中,这样grunt就可以使用它了,还应该确保它安装得很干净。

票数 35
EN

Stack Overflow用户

发布于 2017-06-09 06:55:14

尝试在您的终端中运行以下命令:

代码语言:javascript
复制
npm install phantomjs-prebuilt@2.1.14 --ignore-scripts
票数 9
EN

Stack Overflow用户

发布于 2014-05-10 13:28:15

试试npm install grunt-mocha -D

参见https://github.com/gruntjs/grunt-lib-phantomjs/issues/22的更多详细信息

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18218134

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档