【发布时间】:2015-05-16 04:30:09
【问题描述】:
在我的 Ubuntu VM 上的项目上从本地安装运行 Karma 时,Karma 不会运行,因为 PhantomJS 无法启动。
版本信息:
- PhantomJS(也安装在本地):1.9.16
- 业力:0.12.31
- karma-phantomjs-launcher: 0.1.4
- Ubuntu 14.04.2 LTS
- 节点 0.10.25
相同的脚本在我的 Mac OS 上运行良好(我在运行之前删除了 karma 的全局安装,它仍然有效)。
在 Ubuntu 上,如果我直接通过 ./node_modules/phantomjs/bin/phantomjs 启动 phantomjs,它就可以正常启动。
这是外壳输出:
> ./node_modules/karma/bin/karma start test/karma.conf.js
DEBUG [config]: autoWatch set to false, because of singleRun
DEBUG [plugin]: Loading karma-* from /srv/detectiveui/node_modules
DEBUG [plugin]: Loading plugin /srv/detectiveui/node_modules/karma-jasmine.
DEBUG [plugin]: Loading plugin /srv/detectiveui/node_modules/karma-phantomjs-launcher.
DEBUG [plugin]: Loading plugin /srv/detectiveui/node_modules/karma-spec-reporter.
INFO [karma]: Karma v0.12.31 server started at http://localhost:9876/
INFO [launcher]: Starting browser PhantomJS
DEBUG [temp-dir]: Creating temp dir at /tmp/karma-42625347
DEBUG [launcher]: /srv/detectiveui/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/lib/phantom/bin/phantomjs /tmp/karma-42625347/capture.js
DEBUG [launcher]: Process PhantomJS exited with code 2
ERROR [launcher]: Cannot start PhantomJS
DEBUG [temp-dir]: Cleaning temp dir /tmp/karma-42625347
INFO [launcher]: Trying to start PhantomJS again (1/2).
DEBUG [launcher]: Restarting PhantomJS
DEBUG [temp-dir]: Creating temp dir at /tmp/karma-42625347
DEBUG [launcher]: /srv/detectiveui/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/lib/phantom/bin/phantomjs /tmp/karma-42625347/capture.js /tmp/karma-42625347/capture.js
DEBUG [watcher]: Resolved files:
#...List of my files here that look correct...
DEBUG [launcher]: Process PhantomJS exited with code 2
ERROR [launcher]: Cannot start PhantomJS
DEBUG [temp-dir]: Cleaning temp dir /tmp/karma-42625347
INFO [launcher]: Trying to start PhantomJS again (2/2).
DEBUG [launcher]: Restarting PhantomJS
DEBUG [temp-dir]: Creating temp dir at /tmp/karma-42625347
DEBUG [launcher]: /srv/detectiveui/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/lib/phantom/bin/phantomjs /tmp/karma-42625347/capture.js /tmp/karma-42625347/capture.js /tmp/karma-42625347/capture.js
DEBUG [launcher]: Process PhantomJS exited with code 2
ERROR [launcher]: Cannot start PhantomJS
DEBUG [temp-dir]: Cleaning temp dir /tmp/karma-42625347
ERROR [launcher]: PhantomJS failed 2 times (cannot start). Giving up.
DEBUG [karma]: Run complete, exiting.
DEBUG [launcher]: Disconnecting all browsers
我似乎也可以在端口 9876 手动启动节点服务器,所以这也可能不是问题。
任何帮助将不胜感激。谢谢!
----更新
我创建了一个新的 Ubuntu 环境并再次测试了相同的东西并得到了相同的错误。
【问题讨论】:
-
我遇到了类似的问题,但
exit code 1 -
根据我之前的评论,通过从项目中删除
node_modules目录(已由其他人使用 Macbook)。我再次运行npm install并重新创建了node_modules目录。我们还将node_modules目录添加到.gitignore以避免将来出现此问题。 -
有趣,有机会我一定要再试一次。我在 Mac 主机上使用 Vagrant,这样就可以解释了。稍后我会在测试时发布结果。
-
如果与Mac Os Sierra相关,请将版本改为1.0.0或以上
标签: phantomjs karma-runner ubuntu-14.04